Codeforces 841B - Godsend
题目链接:http://codeforces.com/problemset/problem/841/B
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?
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 answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).
4
1 3 2 3
First
2
2 2
Second
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.
题解:和为奇数第一个赢 和为偶数 没有奇数的话第二个赢 否则 还是第一个赢
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
const int N=;
int main()
{
int n,k;
while(cin>>n){
int t=;
ll sum=;
for(int i=;i<n;i++){
cin>>k;
sum+=k;
if(k%==) t=;
}
if(sum%==) cout<<"First"<<endl;
else {
if(!t) cout<<"Second"<<endl;
else cout<<"First"<<endl;
}
}
return ;
}
Codeforces 841B - Godsend的更多相关文章
- codeforces Round#429 (Div2)
2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...
- Codeforces Round #429 (Div. 2/Div. 1) [ A/_. Generous Kefa ] [ B/_. Godsend ] [ C/A. Leha and Function ] [ D/B. Leha and another game about graph ] [ E/C. On the Bench ] [ _/D. Destiny ]
PROBLEM A/_ - Generous Kefa 题 OvO http://codeforces.com/contest/841/problem/A cf 841a 解 只要不存在某个字母,它的 ...
- 【Codeforces Round #429 (Div. 2) B】 Godsend
[Link]:http://codeforces.com/contest/841/problem/B [Description] 两个人轮流对一个数组玩游戏,第一个人可以把连续的一段为奇数的拿走,第二 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- 【UNIX网络编程(三)】TCP客户/server程序演示样例
上一节给出了TCP网络编程的函数.这一节使用那些基本函数编写一个完毕的TCP客户/server程序演示样例. 该样例运行的过程例如以下: 1.客户从标准输入读入一行文本,并写给server. 2.se ...
- UDP网络通信
网络概念 一.目的 二.IP地址 三.端口 一.目的 目的 : 主要用于让两个用户端的服务器或者客户端,可以实现资源共享和信息传递 二.IP地址 1.作用 : 计算机网络中一台计算机的标识 2.种类 ...
- 解决ios10以上点击缩放的问题
禁止ios10以上点击缩放,代码如下: <script> window.onload=function () { document.addEventListener('touchstart ...
- Cartographer源码阅读(2):Node和MapBuilder对象
上文提到特别注意map_builder_bridge_.AddTrajectory(x,x),查看其中的代码.两点: 首先是map_builder_.AddTrajectoryBuilder(...) ...
- python的类变量和对象变量[转]
原文章:https://www.cnblogs.com/gtarcoder/p/5005897.html __dict__里存着{"属性名":属性值}. python是一种解释性的 ...
- javaScript 数组迭代方法
map 方法 解释:map即映射,返回对每项操作后组成的新数组 let arr=[1,2,3,4,5,6,7,8]; let newArr=arr.map((item)=>{ if(item&g ...
- centos7安装Lua
网官有介绍安装:http://www.lua.org/start.html 由于之前我遇到过致命错误并纪录在:https://blog.csdn.net/bingbingtea/article/det ...
- tf中的run()与eval()【转载】
转自:https://blog.csdn.net/jiaoyangwm/article/details/79248535 1.eval() 其实就是tf.Tensor的Session.run() 的 ...
- zabbix 监控 redis
redis 可以直接使用zabbix官方的模板 模板地址: https://github.com/blacked/zbx_redis_template redis 主机通过脚本把数据推送到zabbi ...
- 命令行方式调用winrar对文件夹进行zip压缩示例代码
调用winRAR进行压缩 using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...