nim游戏板子:异或起点能到的所有点的边。
踩过的坑:异或的值不是边的值,而是如果这个边可以走到就异或1.
其实不用异或也可以,只要判断起点能到的边的奇偶性
#include<iostream>using namespace std;
const int N = 50;
int n;
int a[N];int main()
{cin >> n;for (int i = 0; i < n; i++)cin >> a[i];int res = 0;int idx = 0;for (int i = 0; i < n; i++){if (a[i] == 0) {idx = i; break;}}//cout << idx;for (int i = idx - 1; i != idx; i--){if (i == -1)i = n - 1;if (a[i] == 0)break;res ^= 1;//cout << i << " " << res << endl;}if (res)cout << "YES";else cout << "NO";return 0;
}