CodeFroces 429B Godsend (模拟)

解法:由于第一个人是可以选择任意长度,和为奇数的序列,偶数相对于奇数是可以忽略的,所以当第一个人有奇数个奇数的时候,一次就能取完,必赢。有大于等于2的偶数个的时候,取掉一个变为奇数,第二个人无可奈何,所以也必定为第一个人赢。唯一第一个人会输的就是没有奇数的时候了。

代码如下:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<utility>
#include<stack>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<map>
using namespace std;
const int maxn = 1e6 + 5;
int n;
int a[maxn];
long long sum = 0;
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
	cin >> n;
	int odd = 0; 
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
		if(a[i] % 2 == 1)
			odd++;
	}
	int ans = 0;
	if(odd < 1) {
		ans = 2;
	} else {
		ans = 1;
	}
	if(ans == 1)
		cout << "First" << '\n';
	else
		cout << "Second" << '\n';
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值