Good Luck in CET-4 everybody!
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
problem DescriptionCollege English level Four exam is coming, you are not nervous review? Perhaps the tension even short semester of ACM have no time to practice, anyway I know Kiki and CiCi are so. Of course, as in the examination room infiltration of more than 10 of contemporary college students, Kiki and CiCi know more about the relaxation before the test, the so-called "relaxation Youdao" is the meaning. No, Kiki and CiCi play poker for a while to relax their nerves before they rest every night.
"Upgrade"? "Double buckle"? "Red Five"? Or is it "the landlord"?
Of course not! That's so vulgar ~
As a student of computer college, Kiki and CiCi did not forget the profession when they played cards, the rules of their playing cards were like this:
1, a total of n cards;
2, the two sides take turns to seize the card;
3, the number of each grab card can only be 2 power (ie: 1,2,4,8,16 ... )
4, grasp the card, the outcome of the results also came out: the end of the hand to catch the winner;
Suppose Kiki and CiCi are smart enough (in fact, not to assume that there are not smart students ~), and each time is Kiki first grab, ask who can win it?
Of course, playing cards no matter who wins is not a problem, it is important that the immediate arrival of the CET-4 can have a good state.
Good luck in CET-4 everybody!InputThe input data contains multiple test cases, one row for each test case, and an integer n (1<=n<=1000).OutputIf Kiki can win, please output "Kiki", otherwise output "Cici", the output of each instance takes up one row.Sample Input13Sample OutputKikicici
A typical error code, I made ...
#include <cstdio>#include<iostream>using namespacestd;intMain () {intN, CNT; while(SCANF ("%d", &n)! =EOF) {CNT=0; while(n) {if(n&1) {CNT++; } N>>=1; } printf ("%s\n", cnt&1?"Kiki":"Cici"); } return 0;}
View Code
Correct solution:
#include <cstdio>#include<iostream>using namespacestd;int Base[Ten];BOOLdp[1005];voidInit () { for(intI=0; i<Ten; i++) { Base[I] =1<<i; } for(intI=1; i<= +; i++) {Dp[i]=0; for(intj=0; j<Ten&&Base[j]<=i; J + +) { if(dp[i-Base[J]] ==0) {Dp[i]=1; Break; } } }}intMain () {Init (); intN; while(SCANF ("%d", &n)! =EOF) {printf ("%s\n", Dp[n]?"Kiki":"Cici"); } return 0;}
Of course, the rules can be found by enumerating:
#include <stdio.h>intMain () {intN; while(SCANF ("%d", &n)! =EOF) { if(n%3==0) printf ("cici\n"); Elseprintf ("kiki\n"); }}
HDU 1847--good Luck in CET-4 everybody!