Codeforces841b godsend

阅读全文大概需要 2分钟
本文总阅读量
Posted by yjjr's blog on February 6, 2018

标签:博弈论

Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Twoplayers play the game on the array. Players move one by one. The first playercan choose for his move a subsegment of non-zero length with an odd sum ofnumbers and remove it from the array, after that the remaining parts are gluedtogether into one array and the game continues. The second player can choose asubsegment of non-zero length with an even sum and remove it. Loses the one whocan 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 ofthe 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 onemove and win.

In second sample first player can't make a move and lose.

 

题意:

给定:长度为N的序列,两人做游戏,A先手只能取子段和为奇数的子段,B后手只能取子段和为偶数的子段,轮到谁不能取就输,询问谁最后胜利

分析:这种数据范围,肯定是博弈论辣

如果这个序列整个和为奇数,那么A先手能够一次性取完,A胜利

如果序列和为偶数且整个序列中不存在奇数,那么A先手无法取,B胜利

如果序列和为偶数且整个序列中存在奇数,那么A先手取一个子段和为奇数的子段,此时序列和为奇数,B只能够取一个子段和为偶数的子段,剩下的奇数和子段A第二次取完,A胜利

 

Code

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define mem(x,num) memset(x,num,sizeof x)
#define LL unsigned long long
using namespace std;
LL sum=0,x,n;

int main()
{
	int flag=0;
	scanf("%I64d",&n);
	rep(i,1,n){scanf("%I64d",&x);x=x%2;sum=(sum+x)%2;if(x==1)flag=1;}
	if(sum==0&&flag==0)cout<<"Second\n";
	else cout<<"First\n";
	return 0;
}



本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr