题目链接

http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2220

题目

Description

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 ≤ 1000000) — length of the array.

Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 1000000000).

Output

Output answer in single line.

"First", if first player wins, and "Second" otherwise (without quotes).

Sample Input

4
1 3 2 3

Sample Output

First

题意

两个人进行游戏,给定n和n个数字,第一个人可以拿走和为奇数的一部分数字,第二个人可以拿走和为偶数的一部分数字,谁不能拿走数字则输,问谁能赢

题解

博弈论入门题目,若所有数和为奇数,那么先手可以直接拿走所有数字,后手输,若和为偶数,那么先手可以先拿走一个奇数,此时和为奇数,后手只能拿走和为偶数的部分,剩下的数仍为奇数,先手全部拿走,先手赢,若没有一个奇数全为偶数,先手无法拿走数字,后手赢。

总结一下,即数列中有奇数,先手赢,否则后手赢

AC代码

#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int a;
scanf("%d", &a);
if (a % 2 == 1) {
printf("First");
return 0;
}
}
printf("Second");
return 0;
}
/**********************************************************************
Problem: 2220
User: Artoriax
Language: C++
Result: AC
Time:180 ms
Memory:2024 kb
**********************************************************************/

CSU-2220 Godsend的更多相关文章

  1. CSU 2018年12月月赛 H(2220): Godsend

    Description Leha somehow found an array consisting of n integers. Looking at it, he came up with a t ...

  2. csu 1812: 三角形和矩形 凸包

    传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...

  3. CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...

  4. CSU 1120 病毒(DP)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...

  5. CSU 1116 Kingdoms(枚举最小生成树)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只 ...

  6. CSU 1113 Updating a Dictionary(map容器应用)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...

  7. CSU 1333 Funny Car Racing (最短路)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 解题报告:一个图里面有n个点和m条单向边,注意是单向边,然后每条路开a秒关闭b秒 ...

  8. CSU 1337 搞笑版费马大定理(2013湖南省程序设计竞赛J题)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1337 解题报告:虽然x和y的范围都是10^8,但是如果a 是大于1000的话,那么a^3 ...

  9. CSU 1328 近似回文词(2013湖南省程序设计竞赛A题)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1328 解题报告:中文题题意就不说了.还好数据不大,只有1000,枚举回文串的中心位置,然 ...

随机推荐

  1. pat乙级1034

    1.vs2013不能用scanf,改为scanf_s,但是提交时不能用scanf_s,用scanf... scanf_s(], &a[], &b[], &b[]); 2.c++ ...

  2. 测试发布(maven-assembly-plugin看好你哦)

    项目改成了maven管理,现场需要用增量补丁包的形式发布代码: 2015/4/21 以前试过用ant打补丁包,现在试试maven能不能做同样的事情: maven-assembly-plugin看着可以 ...

  3. 操作表单 -------JavaScrip

    本文摘要:http://www.liaoxuefeng.com/ HTML表单的输入控件主要有以下几种: 文本框,对应的<input type="text">,用于输入 ...

  4. JQuery从服务器端取得数据绑定到dropdownlist(select)中

    http://blog.csdn.net/gaofang2009/article/details/5840783 http://www.cnblogs.com/Mac_Hui/archive/2010 ...

  5. python 读取mat文件

    import osimport scipy.io as sio import numpy as np #matlab文件名 matfn='/home/user/devkit/data/meta_det ...

  6. Echarts样式

    Echarts设置样式如下 <div id="main" style="width: 250px;height:200px;"></div&g ...

  7. SunmmerVocation_Learning--Java数组的创建

    一维数组声明方式: type var[] 或 type[] var; 如int a[], int[] a; Java中声明数组不能指定其长度,如int a[5]是非法的. 一维数组对象的创建: Jav ...

  8. LIS最长上升子序列模板

    LIS n2解法: #include<iostream> #include<cstdio> using namespace std; int n,ans; ],f[]; int ...

  9. 济南NOIP冬令营 选拔(select)

    选拔(select) Time Limit:2000ms   Memory Limit:128MB 题目描述 LYK对n个女生有好感.第i个女生的身高为ai. LYK要在这些女生中选拔出一个女生来作为 ...

  10. mysql 复制一列到另一列

    https://www.cnblogs.com/clphp/p/6251469.html