http://codeforces.com/problemset/problem/841/B
?题目链接
题目大意:有一个长度为n的数组 第一个人从中去掉和为奇数的一部分数字 第二个人去掉和为偶数的一部分数字 轮流进行 谁先无法去除数字谁就输了。
解题思路:第三天写博弈了 这个比较简单
如果总和为奇数 那么先手必胜 全部去掉。
如果总和为偶数 那么要判断其中有没有奇数 如果有奇数 则一定是偶数个奇数 先手只需每次去掉奇数个奇数+任意数量的偶数 则可以保证后手的人无法去除所以奇数 如此往复 先手必胜
如果总和为偶数 并且其中没有奇数 那么先手无法操作 后手必胜
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int eps = 1e-7;
const int maxbit = 30;
const int maxn = 1000000;
const double PI = 3.14;
using namespace std;
int main()
{
ios::sync_with_stdio(0);
int n,m;
int sum = 0;
int flag = 0;
cin >> n;
while (n--) {
cin >> m;
sum += m;
if (m % 2==1)flag=1;
}
if (sum % 2 == 0&&flag==0) cout << "Second\n";
else cout << "First\n";
return 0;
}







Comments | NOTHING