码迷,mamicode.com
首页 > 编程语言 > 详细

【HDU】1850 Being a Good Boy in Spring Festival

时间:2015-02-06 23:08:32      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

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的手速啊= =

【HDU】1850 Being a Good Boy in Spring Festival

标签:

原文地址:http://www.cnblogs.com/iwtwiioi/p/4278122.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!