Codeforces841B Godsend

标签:博弈论

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值