CSU-2220 Godsend
题目链接
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的更多相关文章
- 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 ...
- csu 1812: 三角形和矩形 凸包
传送门:csu 1812: 三角形和矩形 思路:首先,求出三角形的在矩形区域的顶点,矩形在三角形区域的顶点.然后求出所有的交点.这些点构成一个凸包,求凸包面积就OK了. /************** ...
- CSU 1503 点到圆弧的距离(2014湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1503 解题报告:分两种情况就可以了,第一种是那个点跟圆心的连线在那段扇形的圆弧范围内,这 ...
- CSU 1120 病毒(DP)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1120 解题报告:dp,用一个串去更新另一个串,递推方程是: if(b[i] > a ...
- CSU 1116 Kingdoms(枚举最小生成树)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1116 解题报告:一个国家有n个城市,有m条路可以修,修每条路要一定的金币,现在这个国家只 ...
- CSU 1113 Updating a Dictionary(map容器应用)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 解题报告:输入两个字符串,第一个是原来的字典,第二个是新字典,字典中的元素的格式为 ...
- CSU 1333 Funny Car Racing (最短路)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1333 解题报告:一个图里面有n个点和m条单向边,注意是单向边,然后每条路开a秒关闭b秒 ...
- CSU 1337 搞笑版费马大定理(2013湖南省程序设计竞赛J题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1337 解题报告:虽然x和y的范围都是10^8,但是如果a 是大于1000的话,那么a^3 ...
- CSU 1328 近似回文词(2013湖南省程序设计竞赛A题)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1328 解题报告:中文题题意就不说了.还好数据不大,只有1000,枚举回文串的中心位置,然 ...
随机推荐
- 绿盟堡垒机云服务(vSAS-H)
绿盟堡垒机云服务(vSAS-H) 平台: linux 类型: 虚拟机镜像 软件包: basic software devops nsfocus security 堡垒机 服务优惠价: 按服务商许可协议 ...
- SQLSERVER编译与重编译
SQLSERVER编译与重编译 编译的含义 当SQLSERVER收到任何一个指令,包括查询(query).批处理(batch).存储过程.触发器(trigger) .预编译指令(prepared st ...
- WCF的问题
使用service调用WCF的时候,有时候会出现 其他信息: HTTP 无法注册 URL 进程不具有此命名空间的访问权限 这样的问题,这时候就需要进行如下尝试: 1,VS的管理权限使用管理员的权限. ...
- appuim操作webview控件
1.操作webview控件,在uiautomator中如下图,能定位的只有最外层的内容.就一个webview控件,查找不到里面内容 1.使用driver.getContext(),获取是否是webvi ...
- 【51nod1443】路径和树(堆优化dijkstra乱搞)
点此看题面 大致题意:给你一个无向联通图,要求你求出这张图中从u开始的权值和最小的最短路径树的权值之和. 什么是最短路径树? 从\(u\)开始到任意点的最短路径与在原图中相比不变. 题解 既然要求最短 ...
- pytho线程信号量
pytho线程信号量 import threading,time def going(num,sleep_time): semaphore.acquire()#启动允许执行 print("g ...
- C# 文件操作概述
微软的.Net框架为我们提供了基于流的I/O操作方式,这样就大大简化了开发者的工作.因为我们可以对一系列的通用对象进行操作,而不必关心该I/O操作是和本机的文件有关还是和网络中的数据有关..Net框架 ...
- webpack4简单入门
安装webpack需要安装node环境,因此需要在电脑中安装node.node官网https://nodejs.org/,安装LTS版本即可. webpck基本概念 entry:分析依赖模块的入口 o ...
- C语言正整数除法向上取整
在网上发现一个简单的向上取整方法: 这里我们用<>表示向上取整,[]表示向下取整,那么怎么来表示这个值呢? 我们可以证明: <N/M>=[(N-1)/M]+1 (0< ...
- hello spring boot neo4j
新建springboot 项目: https://www.cnblogs.com/lcplcpjava/p/7406253.html bug fixs: 1. Maven Configuration ...