网站源码程序修改/互联网营销模式
sg函数:每堆石子异或操作
最终的状态肯定0^0^0^0 ......^0 = 0
假设每堆石子的数量为xi x1^x2^x3^x4....^xn 这里记为f(x)
f(x) 不为0 则先手必胜 f(x) == 0 先手必败
当f(x) != 0,先手可以走一步到达一种必败的状态0 然后循环 后手必败
当f(x) == 0 时同理
code:
#include<cstdio>using namespace std;int main()
{int n;scanf("%d",&n);int res = 0;for(int i = 1; i <= n ;i ++){int x;scanf("%d",&x);res ^= x;}if(res) printf("Yes\n");else printf("No\n");return 0;
}