Codeforces Round #429(Div.2) B Godsend 博弈

B. Godsend

time limit per test2 seconds
memory limit per test256 megabytes

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 ≤ 10 6 — length of the array.
Next line contains n integers a1, a2, …, an (0 ≤ ai ≤ 10 9 ).

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的由自然数组成的数列。两人玩一个游戏,游戏规则是:
第一个人选择数列中连续若干个和为奇数的数,从数列中移除;第二个人选择数列中连续若干个和为偶数的数,从数列中移除。移除的子串不能为空。如果移除后数列被分成两部分,就把它们按原顺序关系合成新的数列。
当轮到某一方无法操作时,这一方判负。在双方执行最优策略的情况下,输出获胜方。

首先,当原数列中不存在奇数时,显然第二个人胜。接下来考虑原数列中存在奇数的情况:

1.原数列存在奇数个奇数时,第一个人可以把整个数列移除从而取胜。

2.原数列存在偶数个奇数时,注意到第一个人移除的数只能由奇数个奇数和若干个(可为零)偶数组成;第二个人移除的数只能有偶数个奇数和若干个偶数组成(不能同时为零)。那么,在第一个人操作一次后,原数列中的奇数剩下奇数个。此时无论第二个人怎么操作都无法把数列全部移除,且剩下奇数个奇数,这就回到了1的情形。

综上所述,

当原数列中存在奇数时,第一个人取胜;反之则第二个人取胜。

#include<stdio.h>
int main()
{
    int N,x,i;

    scanf("%d",&N);
    for(i=1;i<=N;i++)
    {
        scanf("%d",&x);
        if(x&1)return puts("First"),0;
    }
    puts("Second");
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值