본문 바로가기

pku

PKU 2234. Matches Game. AC get -_-;;; #include int main() { int n, k, sum; while (~scanf("%d", &n)) { sum = 0; while (n--) { scanf("%d", &k); sum ^= k; } if (sum) { printf("Yes\n"); } else { printf("No\n"); } } return 0; } 쩝... 초 간결한 코드입니다. -_-;; 그냥 단순하게 정해진 최대치를 서로 계속 가져간다 했을때, 정해진 최대치에 맞아 떨어져서 최종 갯수가 0이 아니면 이긴거고, 0이면 진거지요 뭐 =ㅁ=;; 더보기
PKU 2234. Matches Game 성냥 놀이 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2658 Accepted: 1536 설명 간단한 게임이 있습니다. 이 게임은 두 명의 플레이어와 여러 개의 쌓여진 성냥개비가 있습니다. 두 명의 플레이어는 턴을 나누어서 진행합니다. 각 턴을 진행하는 플레이어는 쌓여진 성냥개비에서 임의의 성냥개비를 덜어냅니다(물론 덜어낼 성냥개비는 0개이어서는 안되고, 덜어낼 성냥개비는 한 뭉치 안에서만 덜어내야 합니다). 한 플레이어의 턴이 끝나고 나서 성냥이 하나도 남지 않으면, 그 플레이어의 승리가 됩니다. 두 명의 플레이어 모두는 매우 똑똑하다는 가정을 해봅시다. 당신이 할 일은 먼저 플레이 하는 사람이 게임에서 이길지 질지 를 알아내는 것입니다. .. 더보기
PKU 2234. Matches Game Matches Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2658 Accepted: 1536 Description Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of matches, which is taken away, cannot be zero and cannot be .. 더보기
PKU 2243. Knight Moves. AC #include int table[8][8]; void fill(int y, int x, int n) { if(table[y][x] 7 || x>7 || y 더보기
PKU 1454, UVa 324. Factorial Frequencies. AC #include #include #include int n; typedef struct { char *start, *end; int len; }bigint; void make(bigint *a, char *string) { a->len=strlen(string); a->start=realloc(a->start,(a->len+1)*sizeof(char)); memset(a->start,0,sizeof(char)*(a->len+1)); a->end=a->start+(a->len-1); strcpy(a->start, string); } void delete(bigint *a) { free(a->start); } void init(bigint *a) { a->len=1; a->start=calloc(2,size.. 더보기
PKU 2840. Big Clock. AC #include int main() { int t, i, h, m; scanf("%d", &t); for(i=0; i 더보기
PKU 2656. Unhappy Jinjin. AC #include int main() { int n, i, a, b, max, day; scanf("%d", &n); while(n) { max=day=0; for(i=0; i max) { max=a+b; day=i; } } printf((max 더보기
PKU 2243. Knight Moves 나이트의 움직임 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3541 Accepted: 2177 설명 당신의 친구가 TKP 를 조사하고 있고, 당신은 막혀진 공간에서의 나이트의 움직임을 조사해야 하는데 그 조사할 움직임은 주어진 n개의 정사각형 칸들을 한번에 움직이는 방법입니다. 그가 생각하기로, 문제의 가장 어려운 부분은 두 개의 주어진 정사각형의 칸을 나이트가 최소한으로 움직이는 숫자를 결정하는 것이고, 이것은 당신이 예전에 해냈던 것이므로, 찾아내는 것은 쉬울 것입니다. 물론 당신은 그것이 문제를 푸는 그 자체라는 것 또한 알고 있습니다. 그래서 당신은 그 친구에게 "어려운" 부분을 풀 프로그램을 짜도록 제안합니다. 당신이 해야 할 일은 .. 더보기
PKU 2243. Knight Moves Knight Moves Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3541 Accepted: 2177 Description A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the most difficult part of the problem is determining the smal.. 더보기
PKU 2840. Big Clock 대형 시계 Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4397 Accepted: 2802 설명 목사님이 교회의 시계를 수리하기 위해 몇 주간 돈을 모으셨습니다. 그 시계는 매 시간마다 소리를 냈었는데, 몇 주 전에 고장이 난 뒤로 조용했습니다. 시계가 고쳐진 뒤로는, 잘 작동했지만 여전히 문제가 좀 있었습니다. 시계가 1시에는 13번, 2시에는 14번... 12시에는 24번, 13시에는 1번 소리를 냈습니다. 지금은 몇번이나 소리를 낼까요? 입력 첫 번째 줄은 단 하나의 정수 T (T 더보기
PKU 2840. Big Clock Big Clock Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 4397 Accepted: 2802 Description Our vicar raised money to have the church clock repaired for several weeks. The big clock, which used to strike the hours days and nights, was damaged several weeks ago and had been silent since then. After the clock was repaired, it works all right, but there is still something wrong with it: t.. 더보기
PKU 2656. Unhappy Jinjin Unhappy Jinjin Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5645 Accepted: 4199 Description Jinjin is a junior school student. Besides the classes in school, Jinjin's mother also arranges some supplementary classes for her. However, if Jinjin studies for more than eight hours a day, she will be unhappy on that day. On any day she gets unhappy, the more time she studies, the unhappi.. 더보기
PKU 2656. Unhappy Jinjin 우울한 Jinjin Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5645 Accepted: 4199 설명 Jinjin은 초등학생입니다. 학교 수업이 있는데도, Jinjin의 어머니는 그녀가 해야 할 보충수업을 잡았습니다. 그러나 Jinjin은 하루에 8시간을 초과하여 공부하면 그날 우울해집니다. 우울한 날이 되면, 그녀는 공부를 더 하고, 따라서 우울한 정도가 더 심해집니다. 이제 우리는 앞으로 며칠동안 Jinjin의 공부시간을 정해야 하는데, 따라서 당신이 해야 할 일은 그녀가 그 며칠동안 우울해지는지 그렇지 않은지 이고, 만약 우울해진다면 어떤 날이 제일 우울해지는 날일지를 알아내는 것입니다. 입력 여러 테스트 케이스가 있을 것입니다. 각 .. 더보기
PKU 2039. To and Fro. AC #include #include char pwd[210]; int n, len; void rev(char *a, char *b) { char tmp; for(; a 더보기
PKU1455. Crazy tea party. AC get.. #include using namespace std; int main() { int cases, i, n, result, a, b; cin >> cases; for (i = 0; i > n; if(n % 2 == 0) { result = (n / 2 - 1) * n / 2; } else { a = n / 2; b = n - n / 2; result = ((a-1) * a + (b - 1) * b) / 2; } cout 더보기
PKU 1455. Crazy Tea Party 미친 차 파티 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4055 Accepted: 2736 설명 미친 차 파티>>에 참가한 n명의 참가자들이 테이블에 둘러앉아있습니다. 매 분마다 한 쌍의 이웃한 사람들이 서로 자리를 바꿀 수 있습니다. 모든 참가자가 역순으로 앉을때까지 걸리는 시간을 구하세요. 입력 첫 번째 줄은 테스트할 시행횟수입니다. 다음 각 줄은 하나의 양정수 n (1 더보기
PKU 1455. Crazy Tea Party Crazy tea party Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4055 Accepted: 2736 Description n participants of > sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to sit in reverse order (so that left neighbors would become right, and right - left). Input The first line is the amount of .. 더보기
PKU 2719. Faulty Odometer. AC #include #include int table[10]={0,1,2,3,0,4,5,6,7,8}; int cvt(char *str) { int i,nines=1,result=0; for(i=strlen(str)-1; i>=0; i--, nines*=9) result+=(table[str[i]-'0'])*nines; return result; } main() { char str[10]; gets(str); while(str[0]!='0') { printf("%s: %d\n",str,cvt(str)); gets(str); } } 그냥 0,1,2,3,5,6,7,8,9을 사용하는 구진법 숫자를 십진법으로 바꾸면 되는 문제였네요. int e(char*a){int b[]={0,1,2,3,0,4,5,6,7,8},i,.. 더보기
PKU 2719. Faulty Odometer. AC get... a(n,k,nn,sum1,sum2){if(n 더보기
PKU 2719. Faulty Odometer 고장난 주행거리계 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5004 Accepted: 3159 설명 당신은 차의 주행거리를 정수로 표시해주는 주행거리계가 달린 차를 보고 있습니다. 그러나 그 주행거리계는 좀 고장이 나서, 언제나 숫자 4를 뛰어넘고 3에서 5로 바꿔버립니다. 이 고장은 일의 자리 뿐만이 아닌, 각 자리에서 문제를 일으킵니다. 예를 들면 주행거리계가 15339 마일이 표시된 상태에서 1마일을 더 움직이면 주행거리계는 15340 마일이 나오는 대신 15350 마일을 보여줍니다. 입력 각 줄은 1..999999999의 범위 안에 있는, 주행거리계에 표시된 숫자로, 앞자리의 0은 생략한 상태의 양정수로 입력합니다. 입력을 종료할 때.. 더보기
PKU 2719. Faulty Odometer Faulty Odometer Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5004 Accepted: 3159 Description You are given a car odometer which displays the miles traveled as an integer. The odometer has a defect, however: it proceeds from the digit 3 to the digit 5, always skipping over the digit 4. This defect shows up in all positions (the one's, the ten's, the hundred's, etc.). For example, if.. 더보기
UVa 112. Tree summing by Java. AC. -_-..... package test; import java.io.*; public class Main { static DataInputStream dis; static int target; static boolean what; static boolean plus; public static boolean getTarget() throws Exception { int temp1, start = 0; while (((temp1 = dis.read()) != -1)) { if (temp1 == '-') { plus = false; start++; continue; } if (temp1 == '(') { what = true; return true; } if (temp1 == -1) { return false; } if (t.. 더보기
PKU 2551. Ones. Wait for Server-_- #include using namespace std; int main() { int n, i, sum; while(cin >> n) { for(i = 1, sum = 1; sum % n; i++) { sum = (sum % n * 10) + 1; } cout 더보기
PKU 1904. King's Quest. TLE 비재귀함수까지 #include #include #include struct _prince_ { int love[2001]; int marry[2001]; int n; }prince[2001]; int married_prince[2001]; int n; int stack[2][2001]; int *top[2]={&stack[0][0],&stack[1][0]}; void push(int stack_num, int value) { *top[stack_num]++=value; } int pop(int stack_num) { return *(--top[stack_num]); } int is_stack_empty() { if(top[0] == &stack[0][0]) return 1; return 0; } void input().. 더보기
PKU 2551. Ones 1들 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5098 Accepted: 2912 설명 2와 5로 나누어지지 않는 정수 n의 범위가 0 더보기
PKU 2551. Ones Ones Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5098 Accepted: 2912 Description Given any integer 0 더보기
PKU 1904. King's Quest. WA 그냥 모든 경우의 수를 탐색하는 방법입니다. #include struct _prince_ { int love[2001]; int marry[2001]; int n; }prince[2001]; int married_girl[2001]; int n; void input() { int i, j ,k; scanf("%d",&n); for(i=0; i 더보기
이번 문제... 스'뽜'킹씨가 아무래도 우리를 쥑이려고 작정한듯 -_-; 케이스 타임 리밋과 시간제한, 메모리제한, AC비율과 제출형태. -_-;; 문제를 대략 살펴보니 그래프에서의 DFS를 이용해 답을 찾는 문제 같은데(좀 더 계산해봐야 확답 나올듯) 이거 풀다 승질나서 죽을지도 모르겠군요. 쉣. 더보기
PKU 1904. King's Quest 왕의 부탁 Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 1493 Accepted: 494 Case Time Limit: 2000MS 설명 옛날 옛적에 N 명의 아들들이 있는 왕이 있었습니다. 또한 왕궁에는 N명의 아름다운 소녀들이 있었고 N 명의 아들들이 그 소녀들을 좋아한다는 것을 왕이 알아챘습니다. 그러나 왕의 아들들은 젊고 무뇌였기에 한 아들이 여러 명의 소녀를 좋아하는 경우도 있었습니다. 그래서 왕은 마법사에게, 그의 아들들이 각자가 원하는 소녀와 결혼할 수 있도록 하라고 시켰습니다. 그리고 마법사는 그 일을 해내어서 각 왕자가, 결혼하기를 원하는 소녀를 골랐는데, 당연하게도 일부일처제의 방식이었습니다. 그러나 왕은 그 결과를 보고 말.. 더보기
PKU 1904. King's Quest King's Quest Time Limit: 15000MS Memory Limit: 65536K Total Submissions: 1493 Accepted: 494 Case Time Limit: 2000MS Description Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king knew about each of his sons which of those girls he did like. The sons of the king were young and light-headed, so it was possible for one son to like sev.. 더보기