zoj 2083 Win the Game(博弈SG函数)
2020-11-27 23:27
标签:blog class c code http color 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1083 题意差不多是这样,给你n条线的长度,让你染色,每次只能染2个长度单位,让你先染,问是否能赢的胜利 其实这题和取石子的那题(ECNU
1328 Stripes )差不多,都要考虑子情况,一条线染色后变成两段,要分别考虑 上个代码: zoj 2083 Win the Game(博弈SG函数),搜素材,soscw.com zoj 2083 Win the Game(博弈SG函数) 标签:blog class c code http color 原文地址:http://www.cnblogs.com/ccccnzb/p/3734611.html
#include #include #include int f[100],sg[100],hash[100];
void
GetSG()
{ int
i,j;
memset(sg,0,sizeof(sg));
for(i=2;i
{
memset(hash,0,sizeof(hash));
for(j=0;j
{
hash[sg[j]^sg[i-j-2]]=1;
}
for(j=0;j
{
if(hash[j]==0)
{
sg[i]=j;
break;
}
}
}
}int
main()
{ int
i,j,n,m;
GetSG();
while(scanf("%d",&n)!=EOF)
{
int
flag=0;
for(i=0;i
{
scanf("%d",&m);
flag^=sg[m];
}
if(flag==0) printf("No\n");
else
printf("Yes\n");
}
return
0;
}
文章标题:zoj 2083 Win the Game(博弈SG函数)
文章链接:http://soscw.com/essay/22984.html