본문 바로가기

pku

PKU 2871. A Simple Question of Chemistry A Simple Question of Chemistry Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4199 Accepted: 2809 Description Your chemistry lab instructor is a very enthusiastic graduate student who clearly has forgotten what their undergraduate Chemistry 101 lab experience was like. Your instructor has come up with the brilliant idea that you will monitor the temperature of your mixture every minu.. 더보기
PKU 3589. Number-guessing Game 숫자맞추기 게임 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3240 Accepted: 2406 설명 Larry는 숫자맞추기 게임을 좋아합니다. 이 게임은 두 명이 있어야 시작할 수 있는데, 각각을 X와 Y라고 하고 X는 Y가 맞출 숫자를 준비합니다. 이 숫자는 4자리여야 하고, Y에겐 말하지 않은 상태로 Y가 생각하기 시작합니다. Y가 말하면 X는 *A*B의 형태로 대답하여야 하는데, 이 대답은 Y가 생각한 숫자가 X가 생각하고 있던 숫자와 얼마나 근접하였는지를 알려줍니다. A앞에 나오는 숫자는 위치와 숫자가 모두 맞는 것의 개수이고, B앞에 나오는 숫자는 위치는 틀렸지만 숫자가 맞은 것의 개수입니다. 예를 들어, X가 5204 를 생각하였고.. 더보기
PKU 3589. Number-guessing Game Number-guessing Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3240 Accepted: 2406 Description Larry likes playing the number-guessing game. Two players are needed in a game. Suppose they are X and Y, and X presents a number for Y to guess. Firstly, X chooses a number with four different digits, keeping it in mind, and tells Y to start guessing. Every time Y has guessed, X shoul.. 더보기
PKU 1218. THE DRUNK JAILER. AC 문이 홀수번 열리고 닫히면 되니 약수의 개수가 홀수개인 제곱수의 개수를 찾아 출력합니다. #include #include int is_square(int n) { int a, b, count=1; switch(n%10) { case 2: case 3: case 7: case 8: return 0; break; } for(a=2, b=0; (n&1)==0; n>>=1, b++); count*=(b+1); for(a=3; n>1; a+=2) { for(b=0; n%a==0; n/=a, b++); count*=(b+1); } return (count&1); } int run(int n) { int i, count=0; for(i=1; i 더보기
PKU 2853. Sequence Sum Possibili. AC n을 더한 수의 개수로 나누면, 더한 값들의 평균값이 나옵니다. #include #include int run(int n) { int m, lmt, count=0; lmt=sqrt((int)2*n); for(m=2; m 더보기
PKU 3372. Candy Distribution 사탕 나누기 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3678 Accepted: 1902 설명 N 명의 아이들이 원을 이루고 서있고, 1번부터 N번까지 시계방향으로 번호를 매기고서 자신들의 사탕을 받기를 기다리고 있습니다. 담당하는 선생님은 다음의 방법을 따라서 사탕을 나누어주려고 합니다: 우선 선생님이 1번 학생과 2번 학생에게 사탕을 하나씩 줍니다. 그다음 시계방향으로 원을 따라 걸어서 3번 학생은 넘어가고 4번 학생에게 사탕을 줍니다. 그다음 두 명의 학생을 넘어가고 7번 학생에게 사탕을 줍니다. 이러한 방식을 통하여 사탕을 나누어 주려고 합니다. 이제 당신은 모든 학생이 최소한 하나 이상의 사탕을 받을 수 있는지에 대해 선생님에게 알.. 더보기
PKU 3372. Candy Distribution Candy Distribution Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3678 Accepted: 1902 Description N children standing in circle who are numbered 1 through N clockwise are waiting their candies. Their teacher distributes the candies by in the following way: First the teacher gives child No.1 and No.2 a candy each. Then he walks clockwise along the circle, skipping one child (child No... 더보기
PKU 3224. Go for Lab Cup! 연구실 대회! Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 5062 Accepted: 2672 설명 연구실 탁구 대회가 PKU 연구실중 한 곳에서 개최될 예정입니다. AI 연구실의 학생들은 모두 탁구에 열광하며, 이 대회에서 자신들의 연구실에 대해 알려줄 용의가 충만합니다. 그러나 quota에 의하여 단 한 팀만이 대회에 출전할 수 있도록 제한되었습니다. 공정한 선정을 위하여, 참가자들은 5판 3선승의 경기로 결정되는 리그전을 하기로 하였습니다. 가장 많이 이긴 사람이 연구실을 대표할 자격을 얻는 것이지요. 이제 연구실의 대표인 Ava 씨가, 모든 경기의 점수표를 가지고 있습니다. 과연 누가 대회에 나가는 행운을 얻게 될까요? 입력 입력은 하.. 더보기
PKU 3224. Go for Lab Cup! Go for Lab Cup! Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 5062 Accepted: 2672 Description The Lab Cup Table Tennis Competition is going to take place soon among laboratories in PKU. Students from the AI Lab are all extreme enthusiasts in table tennis and hold strong will to represent the lab in the competition. Limited by the quota, however, only one of them can be selected to .. 더보기
PKU 1989. The Cow Lineup 소 정렬 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3397 Accepted: 2028 설명 농부 John이 N마리의 젖소(1 더보기
PKU 1989. The Cow Lineup The Cow Lineup Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3397 Accepted: 2028 Description Farmer John's N cows (1 더보기
PKU 2000. Gold Coins. AC get. #include int main() { int input, input_first, count, p, pay; while(scanf("%d", &input)) { pay = 0; if (input == 0) { break; } input_first = input; count = 1; p = 1; while(input != 0) { input--; pay += count; if (count == p) { p = 1; count++; } else { p++; } } printf("%d %d\n", input_first, pay); } } 걍 열심히 돌리는게 답입니다 =ㅁ=...; 더보기
PKU 2853. Sequence Sum Possibilities. AC get. #include #include int main() { int n, num, input, limit, i, cnt; scanf("%d", &n); while(n--) { scanf("%d%d", &num, &input); cnt = 0; for (i = 1; input > 0; i++) { input -= i; if (!(input % i)) { cnt++; } } printf("%d %d\n", num, cnt - 1); } } ..... 숏코딩입니다. -_-; 더보기
PKU 2665. Trees. AC get. #include using namespace std; int main() { int trees, rodes, i, start, end; while (cin >> trees >> rodes) { if (trees == 0 && rodes == 0) { break; } trees++; for (i = 0; i > start >> end; trees -= (end - start + 1); } cout 더보기
PKU 3673. Cow Multiplication. AC get! #include #include char temp1[256], temp2[256]; int main() { int lt1, lt2, i, j, sum = 0; scanf("%s%s", temp1, temp2); lt1 = strlen(temp1); lt2 = strlen(temp2); for (i = 0; i < lt1; i++) { for (j = 0; j < lt2; j++) { sum = sum + (temp1[i] - '0') * (temp2[j] - '0'); } } printf("%d\n", sum); } 쉽습니다. 곱셈법이 변태같을 뿐; 더보기
PKU 1008, UVa 300. Maya Calendar. AC get. #include #include char *HaabMonth[18]={"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"}; char *TzolkinDay[20]={"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int main() { int n, i; int year, mon.. 더보기
PKU 1547. Clay Bully 찰흙 강탈자(?) Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4783 Accepted: 2896 설명 Terry 씨는 맡은 원생들에게 찰흙을 가지고 놀게 시키기를 좋아하는 어린이집 교사입니다. 그녀가 아이들에게 내주는 과제중의 하나는, 찰흙 덩어리를 가지고 적당한 모양의 덩어리를 만들어서 그 크기를 재보는 것입니다. 그러나 어떤 반에 가던지, 다른 아이의 찰흙을 뺏어서 자신의 덩어리의 크기를 더 크게 만드려고 하는 나쁜 아이들이 있게 마련입니다. 그래서 Terry 씨는 모든 아이들에게 같은 양의 찰흙 덩어리를 줍니다. 이제 당신은, Terry 씨가 과제물의 크기를 재본 뒤에 어떤 나쁜 아이가 어떤 아이의 찰흙을 뺏어서 자신의 덩어리를 크게 만.. 더보기
PKU 1547. Clay Bully Clay Bully Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4783 Accepted: 2896 Description Ms. Terry is a pre-school art teacher who likes to have her students work with clay. One of her assignments is to form a lump of clay into a block and then measure the dimensions of the block. However, in every class, there is always one child who insists on taking some clay from some other chil.. 더보기
PKU 2000. Gold Coins. 금화 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11700 Accepted: 7242 설명 어떤 왕이 근위기사에게 봉급을 금화로 주었습니다. 첫 근무날에는 1 개의 금화를, 그 다음 2일에 걸쳐서 하루에 2 개씩의 금화를, 그 다음 3일에 걸쳐서 하루에 3 개씩의 금화를, 그 다음 4일에 걸쳐서 하루에 4 개씩의 금화를 주는 방식으로 말이지요. 이런 패턴으로 쭉 봉급을 줍니다. 즉 어떤 양정수 N에 대해서, N 일씩 묶어서 N 개씩의 금화를 주고 나면, 근위기사는 그 다음 N + 1 일의 날들 동안 N + 1 개씩의 금화를 받게 되는 거지요. 당신이 작성할 프로그램은 시작하는 날을 첫 번째 근무하는 날로 계산하고, 주어진 날짜동안 근위기사가 .. 더보기
PKU 2000. Gold Coins Gold Coins Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11700 Accepted: 7242 Description The king pays his loyal knight in gold coins. On the first day of his service, the knight receives one gold coin. On each of the next two days (the second and third days of service), the knight receives two gold coins. On each of the next three days (the fourth, fifth, and sixth days of service.. 더보기
PKU 2853. Sequence Sum Possibilities 연속된 수들의 합으로 나타낼 수 있는 경우의 수(?) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3213 Accepted: 2159 설명 대부분의 양정수들은 최소 2개의 연속된 양정수들의 합으로 나타낼 수 있습니다. 예를 들어,6 = 1 + 2 + 3 9 = 5 + 4 = 2 + 3 + 4그러나 8은 이러한 표현이 불가능합니다. 이렇게, 입력된 숫자에 대해서 최소 2개 이상의 연속된 수들의 합으로 나타내는 방법이 얼마나 많이 있는지를 계산하는 프로그램을 작성하세요. 입력 첫 번째 줄은 계산할 숫자의 개수를 나타내는 N (1 ≤ N ≤ 1000)을 적습니다. 그 뒤로 나오는 N 개의 줄에는 각 줄에 계산해야 할 숫자가 하나씩 들어가는데, 각 줄.. 더보기
PKU 2853. Sequence Sem Possibilities Sequence Sum Possibilities Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3213 Accepted: 2159 Description Most positive integers may be written as a sum of a sequence of at least two consecutive positive integers. For instance,6 = 1 + 2 + 3 9 = 5 + 4 = 2 + 3 + 4but 8 cannot be so written. Write a program which will compute how many different ways an input number may be written as a s.. 더보기
PKU 2665. Trees Trees Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5383 Accepted: 3713 Description The road off the east gate of Peking University used to be decorated with a lot of trees. However, because of the construction of a subway, a lot of them are cut down or moved away. Now please help to count how many trees are left. Let's only consider one side of the road. Assume that trees were plan.. 더보기
PKU 3210. Coins 동전들 Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4206 Accepted: 2615 설명 Snoopy가 3개의 동전을 가지고 있습니다. 그러다 어느날 그는 테이블 위에 동전을 던진 후에 그것들중 몇 개를 다시 던져서 전부 앞면 또는 뒷면이 나오게 하는 것을 연습해보았습니다. 여러번의 시도 끝에, 그는 처음에 동전들이 어떤 상태로 놓여지건간에, 한 번에 한 동전을 던지는 조건이 만족되면 두 번만에 원하는 모양으로 동전의 방향을 맞출 수 있고, 모든 동전은 한 번 이상 튕겨질 수 있습니다. 또한, 한 번 이하로 던져서는 목표를 달성할 수 없다는 것도 알게 되었습니다. Snoopy는, 만약 n개의 동전을 가지고 있다면 그것들을 전부 같은 모양으.. 더보기
PKU 3210. Coins Coins Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4206 Accepted: 2615 Description Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had either all heads or all tails facing up. After several attempts, he found that regardless of the initial configuration of the coins, he could always achieve the goal by doing exactly two fl.. 더보기
PKU 3673. Cow Multiplication. AC #include int main() { char str[2][11]; int i, j, sum=0; scanf("%s %s", str[0], str[1]); for(i=0; str[0][i]; i++) for(j=0; str[1][j]; j++) sum += (str[0][i]-'0') * (str[1][j]-'0'); printf("%d", sum); return 0; } 저도 그냥 그대로 풀었습니다. 더보기
PKU 3673. Cow Multiplication Cow Multiplication Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4984 Accepted: 3304 Description Bessie is tired of multiplying pairs of numbers the usual way, so she invented her own style of multiplication. In her style, A*B is equal to the sum of all possible pairwise products between the digits of A and B. For example, the product 123*45 is equal to 1*4 + 1*5 + 2*4 + 2*5 + 3*4 +.. 더보기
PKU 3673. Cow Multiplication 어떤 여자의 곱셈(..) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4984 Accepted: 3304 설명 Bessie 는 평범한 방법으로 쌍을 이룬 수들을 곱하는 것에 대해 지쳐서 그녀 자신만의 곱셈 방법을 발명해냈습니다. 그녀의 방법대로라면, A*B 는 A 와 B의 각 자리수를 뽑아서 한 쌍씩 곱한 값을 전부 더한 값이 됩니다. 예를 들어 123*45의 결과는 1*4+1*5+2*4+2*5+3*4+3*5 = 54 가 됩니다. 두 정수 A와 B(1 ≤ A, B ≤ 1,000,000,000)를 받으면 Bessie의 방법으로 곱셈을 계산하세요. 입력 칸을 두고 떨어져있는 두 개의 정수 A와 B를 입력하는 하나의 줄 출력 Bessie의 방법으로 .. 더보기
PKU 1218. THE DRUNK JAILER 술 취한 간수 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 10751 Accepted: 6990 설명 n 개의 감옥방이 긴 복도에 한없이 붙어있는 감옥이 있습니다. 각 감방에는 죄수들이 있고 문은 잠겨있습니다. 어느날, 간수가 너무 지루해져서 게임을 하나 하기로 했습니다. 1라운드에는 간수가 위스키를 마시고 모든 감방의 문을 엽니다. 2라운드에는 간수가 위스키를 마시고, 2의 배수번호의 감방 문을 잠급니다. 3라운드에는 위스키를 마시고 3의 배수인 감방들에 가서 잠겨있다면 열고, 열려있다면 잠급니다. 이러한 작업을 n라운드까지 반복한 뒤에 마지막 위스키를 마시면 간수는 술에 취해 잠이 듭니다. 죄수들중 일부는 자신들의 감방이 열린 것을 깨닫고 .. 더보기
PKU 1218. THE DRUNK JAILER THE DRUNK JAILER Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 10751 Accepted: 6990 Description A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked. One night, the jailer gets bored and decides to play a game. For round 1 of the game, he takes a drink of whiskey,and then runs down the hall unlocking.. 더보기