【CF Round 429 B. Godsend】
time limit per test 2 seconds
memory limit per test 256 megabytes
input standard input
output standard output
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
input
4
1 3 2 3
output
First
input
2
2 2
output
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.
【翻译】输入一个长度为n的序列,第一个人和第二个人轮流操作,第一个人先操作。第一个人可以取走和为奇数的连续一段,第二个人可以取走和为偶数的连续一段,但是不能不去。两人采取最优策略,最终谁会赢(第一个赢输出Fires,反之输出Second)。
题解:
①分类讨论就可以了:
(1)如果整个序列和为奇数,那么开局First就胜利了。
(2)如果整个序列和为偶数:
[1]如果这个序列没有奇数,那么First没法取,Second赢了。
[2]如果存在奇数,那么必会有偶数个奇数,那么First每次只消去一个奇数,到最后一定是他赢,因为Second始终没法消去奇数个奇数。
#include<stdio.h>
int main()
{
int n,sum=0,_=0,a;scanf("%d",&n);
while(n--)scanf("%d",&a),sum+=a,a&1?_=1:1;
puts(sum&1||_?"First":"Second");return 0;
}//Paul_Guderian
祝母校60岁生日快乐!———Rice_Rabbit
【CF Round 429 B. Godsend】的更多相关文章
- 【CF Round 434 A. k-rounding】
Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...
- 【Codeforces Round #429 (Div. 2) B】 Godsend
[Link]:http://codeforces.com/contest/841/problem/B [Description] 两个人轮流对一个数组玩游戏,第一个人可以把连续的一段为奇数的拿走,第二 ...
- 【CF Round 434 B. Which floor?】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 439 E. The Untended Antiquity】
time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...
- 【CF Round 439 C. The Intriguing Obsession】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 439 B. The Eternal Immortality】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 439 A. The Artful Expedient】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【Codeforces Round #429 (Div. 2) A】Generous Kefa
[Link]:http://codeforces.com/contest/841/problem/A [Description] [Solution] 模拟,贪心,每个朋友尽量地多给气球. [Numb ...
- 【Codeforces Round #429 (Div. 1) B】Leha and another game about graph
[链接]点击打开链接 [题意] 给出一个连通图,并给每个点赋一个d值0或1或-1,要求选出一个边的集合,使得所有的点i要么d[i] == -1,要么 dgree[i] % 2 == d[i],dgr ...
随机推荐
- CCS选择器基础
上周学习了HTML和css的一些基础,今天来夯实一下基础 选择器有: 1.标签选择器 :就是HTML 中的标签 如<p> <h1> <body>等 2.类选择器: ...
- 记一次微信小程序在安卓的白屏问题
在做小程序的时候,做到了一个限时商品售卖,用到了倒计时,因为这个原因导致了安卓手机上使用小程序时,将小程序放入后台运行一段时间后,再次进入小程序后出现了页面白屏或者点击事件失效的情况,这里记录下 1. ...
- 前端调试vConsole
在移动端开发的时候,有时候需要真机调试的时候,没法看到console输出的信息,所以就有这个vConsole的开源插件 很方便就可以查看console输出的信息. 官方地址:https://www.n ...
- MySQL字段属性介绍
引言 这次Qi号分享MySQL字段属性简介.下面资料是Qi号搜集大量资料与个人理解的整理. MySQL提供了一组可以赋给表中各个列的数据类型,每个类型都强制数据满足为该数据类型预先确定的一组规则,例如 ...
- HyperLedger Fabric 1.4 区块链技术发展(1.3)
区块链技术发展经历区块链1.0(数字货币).区块链2.0(数字资产与智能合约)和区块链3.0(各种行业分布式应用落地)三个阶段.区块链在应用上分为公有链(PublicBlockChains).联盟链( ...
- [Codeforces947D]Riverside Curio(思维)
Description 题目链接 Solution 设S[i]表示到第i天总共S[i]几个标记, 那么满足S[i]=m[i]+d[i]+1 m[i]表示水位上的标记数,d[i]表示水位下的标记数 那么 ...
- python协程和IO多路复用
协程介绍 ...
- ios交叉编译dylib
ios交叉编译dylib 因多个静态库,libes,libffmpeg,libmt. libpcap 使用不方便 在封装一层接口,生成动态库(c代码),由IOS app上层调用. IOS_BASE_S ...
- PAT、PMT、SDT详解
下面针对解复用程序详细分析一下PAT,PMT和SDT三类表格的格式. 如下图,四个频道复用 PAT---Program Association Table,节目关联表 .PAT表携带以下信息: (1) ...
- 宝石TD迷宫设计器
说起宝石TD,能追溯到我上高二那会,算来是2005年. 所谓一款TD类的魔兽RPG,宝石TD可以算是达到了TD迷宫的巅峰,三进三出更是别具匠心. 这个迷宫设计器是去年在焦作做的,只完成了迷宫设计功能, ...