acwing892. 台阶-Nim游戏
原题链接:https://www.acwing.com/problem/content/894/
思路
奇数台阶异或和不等于0 先手必胜
奇数台阶异或和等于0 先手必败
代码
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int n;
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
int res = 0;
for(int i = 1; i <= n; i ++)
{
if(i % 2)
{
res ^= a[i];
}
}
if(res) puts("Yes");
else puts("No");
return 0;
}
标签:台阶,游戏,Nim,int,异或,acwing892
From: https://www.cnblogs.com/rdisheng/p/16720648.html