c++ 92

DAY1 중급 - 백준 13699번 (C++)

www.acmicpc.net/problem/13699 13699번: 점화식 다음의 점화식에 의해 정의된 수열 t(n)을 생각하자: t(0)=1 t(n)=t(0)*t(n-1)+t(1)*t(n-2)+...+t(n-1)*t(0) 이 정의에 따르면, t(1)=t(0)*t(0)=1 t(2)=t(0)*t(1)+t(1)*t(0)=2 t(3)=t(0)*t(2)+t(1)*t(1)+t(2)*t(0)=5 ... 주어진 입력 0 ≤ n� www.acmicpc.net #include using namespace std; int main() { int n; long long array[36]; int left,right; long long temp = 0; array[0] = 1; array[1] = 1; cin>>n; for(..

DAY1 초급 - 백준 19575번 (C++)

www.acmicpc.net/problem/19575 19575번: Polynomial 경근이는 수학을 좋아한다. 수학을 너무 좋아하는 나머지 다항식을 빠르게 평가하는 프로그램을 작성했다. 미지수 x로 구성된 다항식 f(x)에서 x에 k를 대입하여 f(k)를 구하는 것을 평가라고 한다 www.acmicpc.net #include using namespace std; int main() { cin.tie(NULL); cin.sync_with_stdio(false); long long N,X,ai,i; long long before; bool first = true; cin>>N>>X; while(N >= 0) { cin>>ai>>i; if(first) { before = ai; first = false; ..

백준 1002번 (C++)

www.acmicpc.net/problem/1002 1002번: 터렛 각 테스트 케이스마다 류재명이 있을 수 있는 위치의 수를 출력한다. 만약 류재명이 있을 수 있는 위치의 개수가 무한대일 경우에는 -1을 출력한다. www.acmicpc.net #include #include using namespace std; void swap(double *r1, double *r2) { double temp = *r1; *r1 = *r2; *r2 = temp; } int main() { int t; int x1,x2,y1,y2; double r1,r2; double distance; cin>>t; while(t-- > 0) { cin>>x1>>y1>>r1>>x2>>y2>>r2; distance = sqrt(pow(..

백준 4153번 (C++)

www.acmicpc.net/problem/4153 4153번: 직각삼각형 입력은 여러개의 테스트케이스로 주어지며 마지막줄에는 0 0 0이 입력된다. 각 테스트케이스는 모두 30,000보다 작은 양의 정수로 주어지며, 각 입력은 변의 길이를 의미한다. www.acmicpc.net #include #include using namespace std; int main() { int array[3]; bool end = false; cin>>array[0]>>array[1]>>array[2]; while(!end) { sort(array,array+3); if(array[2]*array[2] == array[0]*array[0] + array[1]*array[1]) { coutarray[1]>>array[2]..

백준 1085번 (C++)

www.acmicpc.net/problem/1085 1085번: 직사각형에서 탈출 첫째 줄에 x y w h가 주어진다. w와 h는 1,000보다 작거나 같은 자연수이고, x는 1보다 크거나 같고, w-1보다 작거나 같은 자연수이고, y는 1보다 크거나 같고, h-1보다 작거나 같은 자연수이다. www.acmicpc.net #include using namespace std; int main() { int x,y,w,h; int width1, width2, hight1, hight2; int result_w, result_h; cin>>x>>y>>w>>h; width1 = x; hight1 = y; width2 = w-x; hight2 = h-y; if(width1 < width2) result_w = w..

백준 9020번 (C++)

www.acmicpc.net/problem/9020 9020번: 골드바흐의 추측 1보다 큰 자연수 중에서 1과 자기 자신을 제외한 약수가 없는 자연수를 소수라고 한다. 예를 들어, 5는 1과 5를 제외한 약수가 없기 때문에 소수이다. 하지만, 6은 6 = 2 × 3 이기 때문에 소수가 아 www.acmicpc.net #include using namespace std; int main() { int n, input; int temp; int array[10001] = {0}; int result1, result2; int term; array[1] = -1; cin>>n; while(n-- > 0) { cin>>input; temp = input/2; for(int i=2; i

백준 4948번 (C++)

www.acmicpc.net/problem/4948 4948번: 베르트랑 공준 베르트랑 공준은 임의의 자연수 n에 대하여, n보다 크고, 2n보다 작거나 같은 소수는 적어도 하나 존재한다는 내용을 담고 있다. 이 명제는 조제프 베르트랑이 1845년에 추측했고, 파프누티 체비쇼 www.acmicpc.net #include using namespace std; int main() { int n; int count = 0; int array[246913]; array[1] = -1; cin>>n; while(n != 0) { for(int i=2; i

백준 1011번 (C++)

www.acmicpc.net/problem/1011 1011번: Fly me to the Alpha Centauri 우현이는 어린 시절, 지구 외의 다른 행성에서도 인류들이 살아갈 수 있는 미래가 오리라 믿었다. 그리고 그가 지구라는 세상에 발을 내려 놓은 지 23년이 지난 지금, 세계 최연소 ASNA 우주 비행�� www.acmicpc.net #include #include using namespace std; int main() { int t; unsigned int x, y, term; int afterMath; int result = 0; int temp; cin>>t; while(t-- > 0) { cin>>x>>y; term = y-x; afterMath = sqrt(term); if(term..

백준 10250번 (C++)

www.acmicpc.net/problem/10250 10250번: ACM 호텔 문제 ACM 호텔 매니저 지우는 손님이 도착하는 대로 빈 방을 배정하고 있다. 고객 설문조사에 따르면 손님들은 호텔 정문으로부터 걸어서 가장 짧은 거리에 있는 방을 선호한다고 한다. 여러분은 www.acmicpc.net #include using namespace std; int main() { int t; int hight, width, n; int h, w; int temp; int term; int result; cin>>t; for(int i=0; i>hight>>width>>n; h = hight; w = n / hight; temp = h * w; term = n - temp; if(term == 0) { resu..