题目链接https://www.acwing.com/problem/content/894/
题目:
思路:如果先手时,奇数台阶上的值的异或值为0,则先手必败,反之必胜。偶数台阶移到地面需要偶数次,后手移动偶数,先手就移动恢复偶数状态
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int main(){ int n; int a; cin>>n; int sum=0; for(int i=0;i<n;i++){ scanf("%d",&a); if(i%2==0) sum^=a; } if(sum)cout<<"Yes"; else cout<<"No"; return 0; }