题目链接:点击打开链接
Nim博弈。裸题。必败状态为 n堆物品数目的异或值为0.否则必胜。(先手)
#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #define maxn 10100 #define _ll __int64 #define ll long long #define INF 0x3f3f3f3f #define Mod 1000000007 #define pp pair<int,int> #define ull unsigned long long using namespace std; int main() { int n,x,ok; while(~scanf("%d",&n)) { scanf("%d",&ok);--n; while(n--){scanf("%d",&x);ok^=x;} if(ok)puts("Yes"); else puts("No"); } return 0; }
时间: 2024-10-13 13:52:46