标签:style io for amp size sp ad on c
题解:
转化成求Nim-sum
每行黑白棋的初始间距作为每堆石子个数
如果当前为P态,则不管当前选手怎样操作,下一个选手都能使其操作后的局面又变为P态。
Nim-sum = 0,即P态。
#include<cmath> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n, m; while(~scanf("%d%d", &n, &m)) { int sum = 0; for(int i=0; i<n; ++i) { int x, y; scanf("%d%d", &x, &y); sum ^= (abs(x-y)-1); } if(sum==0) puts("BAD LUCK!"); else puts("I WIN!"); } return 0; }
hdu1730 Northcott Game,Nim-sum
标签:style io for amp size sp ad on c
原文地址:http://blog.csdn.net/yew1eb/article/details/38775561