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");
}