CodeForces - 841B-Godsend-思维
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 ≤ 106) — length of the array.
Next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 109).
Output
Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).
Examples
4
1 3 2 3
First
2
2 2
Second
Note
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<stdio.h>
#include<map>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stack>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll; int a[]; int main()
{
int n;
while(cin>>n)
{
ll sum=;
int flag=;
for(int i=;i<n;i++)
{
cin>>a[i];
if(a[i]%==)
flag=;
sum+=a[i];
}
if(sum%==)
cout<<"First"<<endl;
else
{
if(flag==)
cout<<"Second"<<endl;
else
cout<<"First"<<endl;
} }
return ;
}
CodeForces - 841B-Godsend-思维的更多相关文章
- Codeforces 841B - Godsend
题目链接:http://codeforces.com/problemset/problem/841/B Leha somehow found an array consisting of n inte ...
- CodeForces 604C 【思维水题】`
题意: 给你01字符串的长度再给你一个串. 然后你可以在这个串中选择一个起点和一个终点使得这个连续区间内所有的位取反. 求: 经过处理后最多会得到多少次01变换. 例如:0101是4次,0001是2次 ...
- Minimum Integer CodeForces - 1101A (思维+公式)
You are given qq queries in the following form: Given three integers lili, riri and didi, find minim ...
- Codeforces 1038D - Slime - [思维题][DP]
题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史 ...
- AND Graph CodeForces - 987F(思维二进制dfs)
题意:给出n(0≤n≤22)和m,和m个数ai,1 ≤ m ≤ 2n ,0≤ai<2n ,把ai & aj == 0 的连边,求最后有几个连通块 解析:一个一个去找肯定爆,那么就要转换一 ...
- CodeForces - 631C ——(思维题)
Each month Blake gets the report containing main economic indicators of the company "Blake Tech ...
- Almost Acyclic Graph CodeForces - 915D (思维+拓扑排序判环)
Almost Acyclic Graph CodeForces - 915D time limit per test 1 second memory limit per test 256 megaby ...
- Diagonal Walking v.2 CodeForces - 1036B (思维,贪心)
Diagonal Walking v.2 CodeForces - 1036B Mikhail walks on a Cartesian plane. He starts at the point ( ...
- CodeForces - 1102A(思维题)
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...
- Codeforces 135A-Replacement(思维)
A. Replacement time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
随机推荐
- spring controller使用了@ResponseBody却返回xml
使用ajax请求数据 $.ajax({ url:message.rootPath +"/sendMessage.xhtml", type:"post", dat ...
- Java8新特性-日期相关类操作
JDK8以前使用SImpleDateFormate类格式化日期,因为在SImple DateFormate中存在Calendar实例引用,而在caleander中得establish中存在clear( ...
- 利用单臂路由实现VLAN间路由(有1个疑问)
配置PC机: PC1:IP 192.168.1.1 :掩码:255.255.255.0:网关:192.168.1.254 VLAN 10 PC2:IP 192.168.2.1 :掩码:255.255 ...
- 解决:python安装mysqldb模块报 EnvironmentError: mysql_config not found
最近学习python操作mysql需要安装mysqldb模块 出现EnvironmentError: mysql_config not found 经网上查看,需要安装mysql客户端开发库libmy ...
- java反射-学习
使用Java反射机制可以在运行时期获取Java类的信息,可获取以下相关的内容: Class对象 类名 修饰符 包信息 父类 实现的接口 构造器 方法 变量 注解 简单的反射例子: 1.获取class对 ...
- css的9个常用选择器
1.类选择器(通过类名进行选择) <!DOCTYPE html> <html> <head> <title></title> </he ...
- SpringBoot2.x整合Shiro(一)
一:什么是ACL和RBAC: ACL: Access Control List 访问控制列表 以前盛行的一种权限设计,它的核心在于用户直接和权限挂钩 优点:简单易用,开发便捷 缺点:用户和权限直接挂钩 ...
- poj 1144 割点模板题
题目大意: 求割点: 基本思路: tarjan算法,套板子 代码如下: #include<iostream> #include<string> #include<vect ...
- 快速加载testNG 的方法
总共两步 首先建包建类建函数,这个是所有项目共同特点,不多少 1.在程序里写@Test,然后就会报错,光标放到那,然后就会有Add TestNG library的提示,点击就会将TestNG的libr ...
- vue+cesiumjs环境搭建【import引入】
之前写了一遍博客关于vue+cesium的搭建,后面是在index.html里通过script引入的,但是后面要用到指南针的时候发现指南针没法引入了 之前的链接: https://www.cnblo ...