CodeForces - 841B-Godsend-思维
Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?
Input
First line of input data contains single integer n (1 ≤ n ≤ 106) — length of the array.
Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).
Examples
4
1 3 2 3
First
2
2 2
Second
Note
In first sample first player remove whole array in one move and win.
In second sample first player can't make a move and lose.
#include<stdio.h>
#include<map>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stack>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll; int a[]; int main()
{
int n;
while(cin>>n)
{
ll sum=;
int flag=;
for(int i=;i<n;i++)
{
cin>>a[i];
if(a[i]%==)
flag=;
sum+=a[i];
}
if(sum%==)
cout<<"First"<<endl;
else
{
if(flag==)
cout<<"Second"<<endl;
else
cout<<"First"<<endl;
} }
return ;
}
最新文章
- Dubbo_异常_Service启动时默认将方法注册到内网IP
- 夺命雷公狗-----React---13--事件监听
- 【笨嘴拙舌WINDOWS】伟大的变革
- 庞玉栋:浅谈seo优化对于网站建设的重要性
- Linux IPC实践(9) --System V共享内存
- SpriteBuilder修改CCB文件中的子CCB文件需要注意的一个地方
- PuTTY的下载安装和基本使用方法教程
- JavaFX-Application
- Mybatis中映射器实现方式总结
- java BASE64流 输出图片。
- 18. socket io
- 升级win10,提示(RAM)内存不足2G的解决的方法,亲測可行
- 云计算平台管理的三大利器Nagios、Ganglia和Splunk
- X509证书申请以及PKCS#10 详解
- C语言——stdio.h
- java.util.concurrent.locks.LockSupport (讲得比较细)
- go语言 os.Rename() cannot move the file to a different disk drive 怎么办
- html5 video,audio控制播放多次,请求/监测全屏状态
- React 创建自己定义控件
- 浅析Java基本数据类型