CSU 2018年12月月赛 H(2220): Godsend
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个数,第一个人能删去一个连续的子串当且只当这个连续子串所有数之和为奇数,同理第二个人删的是和为偶数的子串,谁不能操作了谁输。考虑这个总串和为偶数的情况,因为为奇数的时候第一个人直接全删了。
当总和为偶数的时候,如果所有的数都是偶数的话,第一个人就没有办法删了,所以第二个人赢,不然那第一个先删去一段子串,剩余的子串之和肯定为奇数。第二个人删去偶数,肯定不能全删了,剩余的肯定是奇数,
那么第一个人必赢。综上,只有所有的数都是偶数的时候第二个人才赢,否则第一个人赢 。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
const int maxn=;
int n,x,temp;
string s;
int main()
{
cin>>n;
bool flag=false;
while(n--)
{
scanf("%d",&x);
if(x%)
flag=true;
}
if(flag==false)
cout<<"Second"<<endl;
else
cout<<"First"<<endl;
return ;
} /**********************************************************************
Problem: 2220
User: therang
Language: C++
Result: AC
Time:256 ms
Memory:2020 kb
**********************************************************************/
CSU 2018年12月月赛 H(2220): Godsend的更多相关文章
- CSU 2018年12月月赛 B 2214: Sequence Magic
Description 有一个1到N的自然数序列1,2,3,...,N-1,N. 我们对它进行M次操作,每次操作将其中连续的一段区间 [Ai,Bi][Ai,Bi] (即第Ai个元素到第Bi个元素之间的 ...
- CSU 2018年12月月赛 G(2219): Coin
Description 有这样一个众所周知的问题: 你面前有7个硬币,其中有一个劣质的(它比正常的硬币轻一点点),你有一个天平,问需要你需要使用天平多少次能保证找到那个劣质的硬币. 众所周知的算法是: ...
- CSU 2018年12月月赛 F(2218): Finding prime numbers
Description xrdog has a number set. There are 95 numbers in this set. They all have something in com ...
- CSU 2018年12月月赛 D 2216 : Words Transformation
Description There are n words, you have to turn them into plural form. If a singular noun ends with ...
- CSU 2018年12月月赛 A 2213: Physics Exam
Description 高中物理老师总认为给学生文本形式的问题比给纯计算形式的问题要求更高.毕竟,学生首先得阅读和理解问题. 因此,他们描述一个问题不像”U=10V,I=5A,P=?”,而是”有一个含 ...
- 2018年12月8日广州.NET微软技术俱乐部活动总结
吕毅写了一篇活动总结,写得很好!原文地址是:https://blog.walterlv.com/post/december-event-microsoft-technology-salon.html ...
- [2018-11-27]2018年12月1日宁波dotnet社区线下活动
离上次活动,转眼又过了一个月,幸得各路大神支持,于本周六(12月1日),宁波dotnet社区的线下分享活动又来啦! 活动嘉宾及主题 董斌辉 2015-2019年微软全球最有价值专家(.NET方向) 2 ...
- CodePlus2017 12月月赛 div2可做题2
11月的月赛错过了,来打12月月赛,由于很(zi)想(ji)拿(tai)衣(ruo)服(la),所以去打div2. T1是一个sb模拟,但是机房全卡死在这道语文题上了,基本上弄了一个半小时,T2可以秒 ...
- csu 10月 月赛 H 题 A Very Hard Problem
Description CX老湿经常被人黑,被黑得多了,自己也就麻木了.于是经常听到有人黑他,他都会深情地说一句:禽兽啊! 一天CX老湿突发奇想,给大家出了一个难题,并且声称谁能够准确地回答出问题才能 ...
随机推荐
- asp.net mvc4 新特性
摘自:ASP.MVC Web编程 几种模板的解释
- Eclipse如何打开Android工程(转载)
转自:http://www.cnblogs.com/kernel-style/p/3339102.html 一.Eclipse如何打开Android工程 1.你可以在file->new-> ...
- bzoj 3239: Discrete Logging && 2480: Spoj3105 Mod【BSGS】
都是BSGS的板子题 此时 \( 0 \leq x \leq p-1 \) 设 \( m=\left \lceil \sqrt{p} \right \rceil ,x=i*m-j \)这里-的作用是避 ...
- A+B Problem——经典中的经典
A+B Problem,这道题,吸收了天地的精华,是当之无愧的经典中的经典中的经典.自古以来OIer都会经过它的历练(这不是白说吗?),下面就有我herobrine来讲讲这道题的各种做法. 好吧,同志 ...
- C/C++带有空格的字符串输入
一.带有空格的字符串输入 (一)C++篇 1. 针对字符数组而言 方法一 getline() 读入整行数据,使用回车键输入换行符来确定输入结尾. 调用方法: cin.getline(str,len) ...
- Bryce1010的操作系统课程设计
https://download.csdn.net/download/fire_to_cheat_/10221003 上面是课程设计的代码,下载需要一些积分. 1.作业调度 2.磁盘调度 常见的磁盘调 ...
- 移动端UI自动化Appium测试——Windows系统Appium环境配置
1.安装JDK,官网下载即可,这里用的1.8,环境变量配置 2.安装Android sdk,API >= 17,环境变量配置 3.安装Nodejs,官网http://nodejs.org/dow ...
- html 相对定位 绝对 定位 css + div
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 0 Transitional//EN""http://www.worg/TR/xh ...
- node入门(一)——安装
node可以让我们用js写服务器.此外还可以用来前端自动化开发,它找到特定服务要使用的包,然后下载.安装.管理. 首先安装node,进入官网下载需要的node版本,然后一键式傻瓜安装.(我的环境是wi ...
- LN : leetcode 712 Minimum ASCII Delete Sum for Two Strings
lc 712 Minimum ASCII Delete Sum for Two Strings 712 Minimum ASCII Delete Sum for Two Strings Given t ...