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 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- MACD:黄白线、红绿柱与0轴关系
一.MACD的基本问题: (1)参数:统一用12,26,9 (2)MACD 位正.位不正原则 以下四种情况是黄白线.红绿柱与0轴关系的完全分类,行情出不了这四种情况, 即便黄白线在0轴单边反复缠绕 ...
- H5-FileReader实现图片预览&Ajax上传文件
图片预览 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...
- "当前不会命中断点,没有与此行关联的可执行代码"可能和"断点位置不准确"有关
今天用VS调试代码遇到一件怪事,在函数结束前的return那一行打了断点,却报"当前不会命中断点,没有与此行关联的可执行代码".看了自己是debug模式,而且没有开启优化,不应该出 ...
- DL中epoch、batch等的意义【转载】
转自:深度学习中 number of training epochs 中的 epoch到底指什么? - 知乎 https://www.zhihu.com/question/43673341 1. (1 ...
- Mybatis select、insert、update、delete 增删改查操作
MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架. MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及对结果集的检索.MyBatis 可以使用简单的XML ...
- js使用的一些实用技巧
1.jquery中页面定时调用ajax方法 function SetContinueSend(param1,param2, func){ func.call(null,param1,param2) } ...
- IdentityServer4:IdentityServer4+API+Client+User实践OAuth2.0密码模式(2)
一.密码模式实操 仍然使用第一节的代码:做如下改动: 1.授权服务端 前面我们使用项目:Practice.IdentityServer作为授权服务器 修改项目的Config.cs类: 添加测试用户,并 ...
- jmeter 二次开发---实现自定义函数插件
1.前提: 有时候,Jmeter自带的函数,可能不能满足于业务的需求,这时候,我们可以自己写一个函数插件: 2.创建maven工程 一直next,输入GroupID,ArtifactId->fi ...
- xml文档对象模型doc
对与DOM来说 ,一切都是节点Node; ②Document可以看成一个节点,Element可以看成一个节点,Text可以看成一个节点, 封装出来的对象都可以看成节点Node; ③在JDK中,Node ...
- 在window下搭建Vue.Js开发环境
nodejs官网http://nodejs.cn/下载安装包,无特殊要求可本地傻瓜式安装,这里选择2017-5-2发布的 v6.10.3,也可选择阿里云镜像https://npm.taobao.org ...