无知的我

先入行,知深浅,再抉择

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.


解题说明:本题是一道模拟题,有一个数组a,两个人玩游戏,游戏规则是第一个人可以拿走数组中的一个子数组并且子数组的和必须是奇数,第二个人可以拿走数组中的一个子数组并且子数组的和必须是偶数。两个人轮流拿,如果谁不能拿,那这个人就输了。如果两个人都采用最好的策略,最后谁赢?如果整个数组和为奇数,那么第一个人肯定赢。 
如果整个数组和为偶数,那么假设第一个人可以取出和为奇数,那么剩下的和还是奇数,所以还是第一个人赢,如果第一个人取不出来,那么第二个人赢。判断第一个人能不能取出来只需统计数组中是否存在奇数就可以。


// codeforece.cpp: 定义控制台应用程序的入口点。
//

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n, odd, temp, i;
	scanf("%d", &n);
	odd = 0;

	while (n--)
	{
		scanf("%d", &temp);
		if (temp % 2 == 1)
		{
			odd = 1;
		}

	}
	if (odd == 0)
	{
		printf("Second\n");
	}
	else
	{
		printf("First\n");
	}
	return 0;
}


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jj12345jj198999/article/details/77971793
个人分类: AC路漫漫
上一篇A. The Useless Toy
下一篇A. Fraction
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭