본문 바로가기

For all category

대학가서 놀라는 선생님의 말씀은 뻥인가요. 이 짤이 진실인가요 더보기
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 2000. Gold Coins. AC #include int gold(int days) { int i, sum=0, time=0, coin=1; for(i=1; i 더보기
15. 20X20그리드의 좌상단에서 출발할 때 우하단으로 가는 길의 개수는? Starting in the top left corner of a 2X2 grid, there are 6 routes (without backtracking) to the bottom right corner. How many routes are there through a 20X20 grid? 2X2그리드의 좌상단에서 우하단으로 가는 길은 6개가 있다. 20X20그리드에선 몇개의 길이 있는가 파스칼의 삼각형을 이용해 풉니다. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 1C0 1C1 2C0 2C1 2C2 3C0 3C1 3C2 3C3 4C0 4C1 4C2 4C3 4C3 5C0 5C1 5C2 5C3 5C4 5C5 nXn그리드에서 길의 개수는 2nCn 입니다. #incl.. 더보기
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 1547. Clay Bully. AC get. #include #include using namespace std; int main() { int num, sum, s[10], i, a, b, c, avg; string names[10], robber, robbed; while (cin >> num) { sum = 0; if (num == -1) { break; } for (i = 0; i > a >> b >> c >> names[i]; s[i] = a * b * c; sum += s[i]; } avg = sum / i; for (i = 0; i avg) { robber = names[i]; } if (s[i] < avg) { robbed = names[i]; } } cout 더보기
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.. 더보기
14. 3n+1 The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is though.. 더보기
PKU 1547. Clay Bully. [판정:RE] 우선, 스파킹군이 dimension을 잘못 번역해놓아서 (고의는 아니었겠지만) 문제의 이해가 다소 어려웠습니다 =_=; 여기선 dimension을 완성된 과제물의 부피로 해석해야 입출력 예시와 들어맞습니다 ㅋㅋ #include #include typedef struct student { int dimension; char name[12]; } student; int dscanf( int *pnum ) { scanf("%d", pnum); return *pnum; } void main() { int n; student list[8]; int i; while( dscanf(&n) != -1 ) { int temp; char tempstr[12]; int min, minindex; int max, maxind.. 더보기
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.. 더보기
13. 100개의 50자리 수의 합에서 앞의 10자리 출력 이 숫자들의 합에서 앞의 10자리를 출력 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 91942213363574161572522430563301811072406154908250 23067588207539346171171980310421047513778063246676 89261670696623633820136378418383684178734361726757 28112879812849979408065481931592621691275889832738 442742289174325203.. 더보기
12. 500개 이상의 약수를 가진 트라이앵글 숫자는 무엇인가 The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,3 6: 1,2,3,6 10: 1,2,5,10 15: 1,3,5,15 21: 1,3,7,21 28: 1,2,4,7,14,28We can see that 28 is the first triangle n.. 더보기
어이 Mr.K 미안허이 ㅡ_ㅡ 근데 난 지금 맡고있던 포스트도 없잖여? 그리고 니 말이 맞았다 -_- 담배 안피우니 손이 잘맞아 -_- 조만간 복귀할듯 더보기
PKU 2853. Sequence Sum Possibilities. [판정:TLE] ㅋㅋ 이럴수가 :( 인수분해를 하고 나서 그 인수들을 다시 곱하는 방법으로 약수들을 다 구했습니다만 -_-; (이때, 인수분해를 통해 나온 인수들에 2를 하나 추가해서 구했습니다) 여전히 TLE가 뜨네요 ㅠ (Run ID : 5826748) #include #include #include int integer( double d ); int isprime( int n ); void reset(); void factorize( int n ); int spread(); int possibility( int n ); // 1st row is primes, 2nd row is power of primes int primeset[2][11] = {0}; int added[11] = {1, 0}; // 1 + pow.. 더보기
PKU 2000. Gold Coins. [판정:AC] 역시 -_-; 이건 쉬운문제였군요 -_-ㅋ 군수열을 응용하면 간단하게 풀립니다 :) #include int dscanf( int *pnum ) { scanf("%d", pnum); return *pnum; } int sigma_k( int n ) { return n * (n+1) / 2; } int sigma_ksquare( int n ) { return n * (n+1) * (2*n+1) / 6; } void main() { int day; int temp, i; while( dscanf(&day) != 0 ) { i = 0; do { i++; temp = sigma_k(i); } while( day >= temp ); i--; temp = sigma_k(i); if( day == temp ) { pr.. 더보기
PKU 서버 맛이 간듯 ㅋ 아니면 점검중이거나 -_-; 금화를 읽고보니 그닥 어려운 문제가 아니라서 방금 다 풀긴 했습니다만 제출할 수가 없네요 지금은 -_-; 더보기
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.. 더보기
11. 20X20그리드에서 인접한 4개의 수로 만들수 있는 가장 큰 곱이 뭘까? In the 20X20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 9.. 더보기
PKU 2853. Sequence Sum Possibilities. [판정:TLE] ㅋㅋ 또 TLE입니다 -_-; 첫번째 TLE는 요놈이구요 (Run ID : 5768623) #include #include #include int integer( double d ) { if( floor(d) == ceil(d) ) return 1; else return 0; } int isprime( int n ) { int i, sq; if( n 더보기
bigint class 완성 #include #include #include #include #include class bigint { private: char sign;//+:0, -:1 unsigned *dats;//가장 뒷자리가 dats[0]에 저장 unsigned len;//dats배열 길이 public: unsigned cona2u(char*); bigint(); ~bigint(); bigint(const int); bigint(const char*); bigint(const bigint &); unsigned resize(unsigned);//길이조절 unsigned resize();//앞의 0 지우기 bigint abs();//절대값 bigint negative(unsigned);//1의보수 int cmp(bigint .. 더보기
10. 200만 미만의 소수의 합을 구해 The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. 10미만의 소수들의 합은 2 + 3 + 5 + 7 = 17이다. 200만 미만의 소수들의 합을 구하여라. 짝수인 소수는 2밖에 없으니 sum=2로 초기화 해주고 홀수만 확인합니다. is_prime함수도 홀수만 확인하니 i=3부터 나머지를 확인합니다. #include #include int is_prime(int a) { int i, sqrn=(int)sqrt(a); for(i=3; i 더보기
PKU 2853. Sequence Sum Possibilities. [판정:TLE] ㅋㅋ 오랜만에 받아보는 TLE입니다 소스는 지금 활동하는 사람이 없어서 안올리고 판정 결과 찍은것만 올릴랬더니 이마저도 시스템 문제로 사진 업로드 불가 ㅋㅋ.. 더보기