【HDU】1850 Being a Good Boy in Spring Festival

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
", as);
	}
	return 0;
}

  


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

好像到cf的手速啊= =

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