Topic Links:
http://acm.hdu.edu.cn/showproblem.php?pid=1847
Good Luck in CET-4 everybody!Time
limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4675 Accepted Submission (s): 2999
Problem Description College English level Four exam is coming, are you in a tense 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!
Input data contains multiple test cases, one row for each test case, and an integer n (1<=n<=1000).
Output if Kiki can win, please export "Kiki", otherwise please output "Cici", the output of each instance is one row.
Sample Input
13
Sample Output
Kikicici
Authorlcy
SOURCEACM Short Term EXAM_2007/12/13
Recommendlcy | We have carefully selected several similar problems for you:1849 1846 2149 2188 1404
Statistic | Submit | Discuss | Note
Topic Meaning:
There are n cards, two people take turns to grasp, each can catch 2 power of the number of cards, to ask who will win.
n<=1000
Problem Solving Ideas:
The SG function is simple to apply.
The Power table of 2 is called out. Then the SG function of each state is deduced, and finally the sg[n] is determined to be 0, and 0 is the state of loss, otherwise it will win.
Code:
#include <CSpreadSheet.h> #include <iostream> #include <cmath> #include <cstdio> #include <sstream> #include <cstdlib> #include <string> #include <string.h> #include <cstring># include<algorithm> #include <vector> #include <map> #include <set> #include <stack># include<list> #include <queue> #include <ctime> #include <bitset> #include <cmath># Define EPS 1e-6#define INF 0x3f3f3f3f#define PI acos ( -1.0) #define LL __int64#define ll long long#define Lson l,m, (RT<&L t;1) #define Rson m+1,r, (rt<<1) |1#define m 1000000007//#pragma comment (linker, "/stack:1024000000,1024000000") using namespace std; #define MAXN 1100int sg[maxn],ba[maxn],cnt,n,temp[maxn];void init () {ba[0]=1; for (int i=1;i<=9;i++)//Hit 2 power number within 1000 ba[i]=ba[i-1]*2; cnt=9; memset (sg,-1,sizeof (SG)); sg[0]=0; for (int i=1;i<=1000;i++)//Find out the SG value of all states {memset (temp,-1,sizeof (temp)); for (int j=0;j<=cnt& &ba[j]<=i;j++) temp[sg[i-ba[j]]]=0; for (int j=0;; J + +) if (temp[j]==-1)//First number not appearing {sg[i]=j; Break }}}int Main () {//freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout); Init (); while (~SCANF ("%d", &n)) {if (Sg[n])//Win printf ("kiki\n") first; else printf ("cici\n"); } return 0;}