Good Luck in CET-4 Everybody!
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 3552 Accepted Submission (s): 2232
Problem Description
The CET-4 is coming soon. Are you busy reviewing? Maybe even the short term ACM has no time to practice. I know Kiki and Cici. Of course, Kiki and Cici, as contemporary college students infiltrated more than a dozen years in the test room, better understand the relaxation before the test. The so-called "Zhang Chi youdao" means this. No, Kiki and Cici have to play cards for a while before taking a rest every night to relax their nerves.
"Upgrade "? "Double buckle "? "Red Five "? Or "Landlords "?
Of course not! That's cool ~
As a computer school student, Kiki and Cici did not forget their major when playing cards. The rules for playing cards are as follows:
1. A total of n cards;
2. Both parties take turns to capture cards;
3. The number of cards each time can only be a power of 2 (I .e., 1, 2, 4, 8, 16 ...)
4. After the cards are captured, the winning and losing results also come out: the people who have finished the cards are the winners;
Suppose Kiki and Cici are both smart enough (in fact, you don't have to assume that there are unintelligent students ~), In addition, Kiki takes the cards first. Who can win?
Of course, no matter who wins cards are not a problem, it is important that the upcoming CET-4 can have a good state.
Good luck in CET-4 everybody!
Input
The input data contains multiple test cases. Each test case occupies one row and contains an integer of n (1 <=n <= 1000 ).
Output
If Kiki can win, output "Kiki"; otherwise, output "Cici", which occupies one line for each instance.
Sample Input
1
3
Sample Output
Kiki
Cici
Author
Lcy
Source
ACM Short Term Exam_2007/12/13
Recommend
Lcy
First method Law: according to the characteristics of the winning and losing Modes
P is a mandatory defeat. N is a mandatory victory.
Then x 0 1 2 3 4 5 6 7 8 9 10 11 12
Status P N P
Therefore, the three multiples are mandatory, so
#include<stdio.h>int main(){ int i,j,n; while(scanf("%d",&n)!=EOF) { if(n%3==0) printf("Cici\n"); else printf("Kiki\n"); } return 0;}
Another method is to find the SG function.
# Include <stdio. h> # include <string. h> int SG [1111], vis [1111]; void get_sg () {int I, j, num [20]; for (I = 0; I <= 10; I ++) num [I] = 1 <I; for (I = 0; I <= 1000; I ++) {if (! SG [I]) // mandatory/failed state for (j = 0; j <= 10; j ++) {if (I + num [j] <= 1000) SG [I + num [j] = 1; // wins} int main () {int n, I, j; get_sg (); while (scanf ("% d", & n )! = EOF) {if (SG [n] = 1) {printf ("Kiki \ n");} else printf ("Cici \ n");} return 0 ;}