AcWing 893. 集合-Nim游戏
标签:stream put ring ems ret nbsp ++ class memset
//只能拿某些特定个数的石子
#include
#include
#include
#include using namespace std;
const int N = 110, M = 10010;
int n, m;
int s[N], f[M];
int sg(int x) {
if (f[x] != -1) return f[x];
unordered_setint> S;
for (int i = 0; i ) {
int sum = s[i];
if (x >= sum) S.insert(sg(x - sum));
}
for (int i = 0; ; i ++ )
if (!S.count(i))
return f[x] = i;
}
int main() {
cin >> m;
for (int i = 0; i > s[i];
cin >> n;
memset(f, -1, sizeof f);
int res = 0;
for (int i = 0; i ) {
int x;
cin >> x;
res ^= sg(x);
}
if (res) puts("Yes");
else puts("No");
return 0;
}
AcWing 893. 集合-Nim游戏
标签:stream put ring ems ret nbsp ++ class memset
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/11918945.html
评论