该题是昨晚的BC第二题, 一道挺简单的博弈题。
对于博弈题, 关键是要找出必败态或者必胜态。 不难发现, 当所选择的数字是当前数组的中间数字时, 无论怎么选, 对手都能恢复到这个局面,那么当前选手必败。
所以所选择的数字不是原数组的中间数字, 那么先手必胜。
细节参见代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define Max(a,b) a>b?a:b
#define Min(a,b) a<b?a:b
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int maxn = 100+5;
int T,n,m;
char s1[maxn], s2[maxn];
int main() {
scanf("%d",&T);
while(T--) {
scanf("%d",&n);
printf("%d\n",n%2 == 0 ? 0 : 1);
}
return 0;
}