7
7
2015
0

hdu 1847: Good Luck in CET-4 Everybody!

还是sg函数,把hdu1848改改贴上就行了= =

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

int mi[100],sg[1010],a[1010];

int main(){
	for(int i=0;mi[i-1]<=1000;i++){
		mi[i]=(1<<i);
	}
	sg[0]=0;
	for(int i=1;i<=1001;i++){
		sg[i]=i;
		memset(a,0,sizeof(a));
		for(int j=0;mi[j]<=i;j++){
			a[sg[i-mi[j]]]=1;
		}
		for(int j=0;j<=1001;j++){
			if(a[j]==0){
				sg[i]=j;
				break;
			}
		}
	}
	int n;
	while(cin>>n){
		if((sg[n])==0){
			printf("Cici\n");
		}else{
			printf("Kiki\n");
		}
	}
	return 0;
}
Category: 博弈论 | Tags: HDU 博弈论 | Read Count: 382

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com