Introduction to Game theory and introduction of the SG function A better blog: Click the Open link
Title Address: Click to open the link
The problem can be done either with the SG function, or by the definition of PN (must-fail and win-state).
SG function Code:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int MAXN = 1e3+5;
int p[11] = {1, 2, 4, 8, +, (+), (+), [n], +, SG[MAXN], BOOK[MAXN];
void Solve ()
{for
(int i = 1; I <=-i++)
{
memset (book, 0, sizeof);
int j = 0;
while (I-p[j] >= 0)
{
book[sg[i-p[j]]] = 1;
j + +;
}
for (j = 0; book[j]; j + +);
Sg[i] = j, j = 0;
}
}
int main (void)
{
solve ();
int n;
while (CIN >> N)
puts (Sg[n]? "Kiki": "Cici");
return 0;
}
PN Code:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1e3+5;
int PN[MAXN], p[11] = {1, 2, 4, 8, +, +,,-
void Solve ()
{for
(int i = 0, i < MAXN; i++)
if (!pn[i])
{for
(int j = 0; I+p[j] < MAXN; j + +)
PN[I+P[J]] = 1;
}
}
int main (void)
{
solve ();
int n;
while (CIN >> N)
puts (Pn[n]? "Kiki": "Cici");
return 0;
}
good Luck in CET-4 everybody! Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 9013 Accepted Submission (s): 5836
Problem Description College English level Four exam is coming, you are not 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 a "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
1 3
Sample Output
Kiki Cici
Author LCY
Source ACM Short Term EXAM_2007/12/13
Recommend LCY