
正文
Be the Winner HDU - 2509(反博弈。。这样叫应该没错吧。。)
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
就是 好几堆苹果 每堆苹果排成一条线 可以任意从每堆拿苹果 如果一堆苹果里拿了之后 则有两种情况
1、从不是边缘拿 拿完这一堆变成两堆
2、从边缘拿 拿完还是一堆
题目还要求 谁拿最后一堆 谁输。。这种类型的分析看这个吧 https://www.cnblogs.com/WTSRUVF/p/9339499.html
看着其他人直接异或。。我还是练一下sg吧。。。。
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int sg[maxn];
int w;
void mex()
{
mem(sg, );
bool vis[maxn];
for(int i=; i<=w; i++)
{
mem(vis, );
for(int j=; j<=i; j++)
{
vis[sg[i-j]] = ;
int tot = i-j;
for(int k=; k<tot; k++)
vis[sg[k]^sg[tot-k]] = ;
}
for(int j=; ; j++)
if(!vis[j])
{
sg[i] = j;
break;
}
}
}int main()
{
int n;
while(cin>> n)
{
int cnt = , res = ;
for(int i=; i<n; i++)
{
cin>> w;
mex();
res ^= sg[w];
if(w == ) cnt++;
}
if(res && cnt != n)
cout<< "Yes" <<endl;
else if(!res && cnt == n)
cout<< "Yes" <<endl;
else
cout<< "No" <<endl; } return ;
}






