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 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- centos who命令 查看当前登录系统用户信息
who 显示当前登录系统的用户,但w显示的更为详细 默认输出 [root@mysql ~]# who //用户名.登录终端.登录时间 root pts/ -- : (192.168.0.110) -a ...
- 关于ARMv8另外几个问题
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/qianlong4526888/article/details/27510675 问题1:支持ARMv ...
- JsonDataObjects基本演示
下载地址https://github.com/ahausladen/JsonDataObjects 执行程序截图 Json数据 { "name": "张三", ...
- MySQL语法和用户授权
管理数据库 create database 等同于 create schema #导入数据库脚本 MariaDB [db1]> source /root/mysql/hellodb_in ...
- 1: process
https://blogs.sap.com/2013/08/20/creating-a-search-page-sap-crm-70-ehp-1/ https://www.cnblogs.com/sa ...
- 使用shape设置android控件只有部分边框有颜色
<?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android=" ...
- Apache服务安全加固
一.账号设置 以专门的用户帐号和用户组运行 Apache 服务. 根据需要,为 Apache 服务创建用户及用户组.如果没有设置用户和组,则新建用户,并在 Apache 配置文件中进行指定. 创建 A ...
- 函数 return
return 的作用 一.返回一个值给函数,主函数调用这个函数后能得到这个返回的值.二.结束函数,例如你运行到一个地方,虽然后面还有代码但是你不想再继续运行,这时就可以直接用 return:这条语句来 ...
- python更新zip文件中文件
#更新zip文件中某一个文件import os import shutil import tempfile import zipfile from rat_tool.pack import * too ...
- Sql之left join(左关联)、right join(右关联)、inner join(自关联)的区别
参考:https://blog.csdn.net/hj7jay/article/details/51749863