AcWing 894. 拆分-Nim游戏
标签:color cin iostream div ret include std count nbsp
#include
#include
#include
#include using namespace std;
const int N = 110;
int n;
int f[N];
int sg(int x) {
if (f[x] != -1) return f[x];
unordered_setint> S;
for (int i = 0; i )
for (int j = 0; j )
S.insert(sg(i) ^ sg(j));
for (int i = 0;; i ++ )
if (!S.count(i))
return f[x] = i;
}
int main() {
cin >> n;
memset(f, -1, sizeof f);
int res = 0;
while (n -- ) {
int x;
cin >> x;
res ^= sg(x);
}
if (res) puts("Yes");
else puts("No");
return 0;
}
AcWing 894. 拆分-Nim游戏
标签:color cin iostream div ret include std count nbsp
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/11918946.html
评论