只有一句话,那个n % 3的规律是怎么找粗来的=_=
SG版:
//HDU-1847.cpp
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
//const double pai = acos(-1.0);
const double pai = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
typedef long long love_live;
int sg[1117];
void init(){
memset(sg, -1, sizeof(sg));
sg[0] = 0;
return ;
}
int getsg(int x){
if(sg[x] != -1){
return sg[x];
}
int i, j, k;
bool mex[1007] = {0};
for(i = 0; i <= 10; ++i){
int op = (1 << i);
int ans = x - op;
if(ans >= 0){
int tmp = getsg(ans);
mex[tmp] = 1;
}
else{
break;
}
}
for(i = 0; ; ++i){
if(!mex[i]){
return sg[x] = i;
}
}
}
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
// freopen("output", "w", stdout);
freopen("input", "r", stdin);
#endif
int n, m, i, j, k;
while(scanf("%d", &n) != EOF){
init();
getsg(n);
// for(i = 0; i <= n; ++i){
// cout << sg[i] << " ";
// }
// cout << endl;
// cout << sg[n] << endl;
if(sg[n] == 0){
printf("Cici\n");
}
else{
printf("Kiki\n");
}
}
return 0;
}
找规律版:
// HDUOJ 1847
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <stack>
#include <map>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const double pai = 3.14159265358979323846;
int main(){
int n;
while(scanf("%d", &n) != EOF){
if(n % 3 == 0){
printf("Cici\n");
}
else{
printf("Kiki\n");
}
}
return 0;
}