您的位置:首页 > 编程语言 > Java开发

【HDU】1850 Being a Good Boy in Spring Festival

2015-02-06 22:17 253 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1850

题意:同nim...顺便求方案数...

#include <cstdio>
#include <cstring>
using namespace std;
int a[105];
int main() {
int n;
while(scanf("%d", &n), n) {
int ans=0, t, as=0;
for(int i=0; i<n; ++i) { scanf("%d", &a[i]); ans^=a[i]; }
for(int i=0; i<n; ++i) {
t=ans^a[i];
if(t<a[i]) ++as;
}
printf("%d\n", as);
}
return 0;
}


  

由于每次取一堆的...由sg的性质及博弈论的性质...整个局面的sg和 xor 当前堆的sg后,只需要知道得到的局面sg和能否由当前堆的i副牌变成游戏和为0即可,即必胜态转移到必败态,即sg=0。。

好像到cf的手速啊= =
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: