HDU 1847 Good Luck in CET-4 Everybody! (Find regular version of Bashi game), hducet-4
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 11740 Accepted Submission (s): 7620
Problem Description CET4 is coming soon. Are you reviewing it hard? 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!
The Input data contains multiple test cases. Each test case occupies one row and contains an integer n (1 <=n <= 1000 ).
Output if Kiki can win, Output "Kiki"; otherwise, Output "Cici". The Output of each instance occupies one line.
Sample Input13
Sample OutputKikiCici
Authorlcy
SourceACM Short Term Exam_2007/12/13
Recommendlcy | We have carefully selected several similar problems for you: 1848 1849 1850 2147
It's a bit similar to bashboyi.
Let's summarize the practices for this question.
1. Rule of brute force manual play
2. Find the rule based on the nature of the winning and losing states
3. Rule of finding SG functions for brute force computing
In the end, it is not difficult to get the final rule: if it is a multiple of three, it will win, otherwise it will lose.
The reason is very simple. The third is a point of defeat. Therefore, both the first hand and the second hand will try to change the number of stones to a multiple of 3.
#include<cstdio>#include<algorithm>using namespace std;const int MAXN=1e6+10,INF=1e9+10;inline int read(){ char c=getchar();int x=0,f=1; while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();} return x*f;}int main(){ #ifdef WIN32 freopen("a.in","r",stdin); #else #endif int n; while(scanf("%d",&n)!=EOF) { if(n%3) printf("Kiki\n"); else printf("Cici\n"); } return 0;}