题目链接: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?

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
Input
41 3 2 3

Output
First

Input
22 2

Output
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.

题解:和为奇数第一个赢 和为偶数 没有奇数的话第二个赢 否则 还是第一个赢

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <algorithm>
 6 #include <cmath>
 7 using namespace std;
 8 #define ll long long
 9 const int N=10005;
10 int main()
11 {
12     int n,k;
13     while(cin>>n){
14         int t=0;
15         ll sum=0;
16         for(int i=0;i<n;i++){
17             cin>>k;
18             sum+=k;
19             if(k%2==1) t=1;
20         }
21         if(sum%2==1) cout<<"First"<<endl;
22         else {
23             if(!t) cout<<"Second"<<endl;
24             else cout<<"First"<<endl;
25         }
26     }
27     return 0;
28 }

转载于:https://www.cnblogs.com/shixinzei/p/7428307.html

Codeforces 841B - Godsend相关推荐

  1. codeforces 841B Godsend

    http://codeforces.com/contest/841/problem/B 一道奇偶博弈题,两个人轮流拿一串数列中的数字,第一个人能拿总和为奇数的数字,第二个人能拿总和为偶数的数字. 如果 ...

  2. Codeforces 841B Godsend 博弈

    题意:给一串序列,第一个人可以从中随意取出和为奇数的子串,第二个人可以从中取出和为偶数的子串,第一个人先走,若到某个人时其无法进行操作,则其输.求出赢的那个人是谁 思路:如果在某步中某个人可以取完所有 ...

  3. G - Godsend CodeForces - 841B

    网址:https://cn.vjudge.net/contest/236128#problem/G 给定一个n个整数的序列,两个玩家玩游戏,轮流进行操作(从第一个玩家开始),第一个玩家移除的数之和必须 ...

  4. CodeForces 841B (B) 博弈

    题意 定义A把取数列中区间和为奇数的元素取出来 B把数列中区间长度为偶数的区间删除 那么谁先面临无数可拿的局面为输 输出赢家 A先取 分析 分析可知本题如果区间中每一个数是偶数那么B可以一次取完 则A ...

  5. codefroces 841B Godsend

    想法题 如果数的和为奇数 那么first直接全部拿走 如果数的和为偶数,分两种情况: 1.如果每个数都是偶数 那么first无法拿走任何数 second赢 2.如果存在奇数(肯定是偶数个): ①如果某 ...

  6. codeforces Round#429 (Div2)

    2017-08-20 10:00:37 writer:pprp 用头文件#include <bits/stdc++.h>很方便 A. Generous Kefa codeforces 84 ...

  7. Codeforces 题目合集+分类+代码 【Updating...】【361 in total】

    961A - Tetris                                                模拟                                      ...

  8. 2463: [中山市选2009]谁能赢呢? Codeforces Round #429 (Div. 2) B. Godsend noip三国游戏...

    Description 小明和小红经常玩一个博弈游戏.给定一个n×n的棋盘,一个石头被放在棋盘的左上角.他们轮流移动石头.每一回合,选手只能把石头向上,下,左,右四个方向移动一格,并且要求移动到的格子 ...

  9. Codeforces Round #429 (Div. 2) B. Godsend

    Problem - B - Codeforces 题意: 给定一个数列,先手可以remove一段区间和为奇数的区间,后手可以remove一段区间和为偶数的区间,问你赢家是谁? 思路: 博弈题按状态的思 ...

最新文章

  1. 一台物理机上VMware虚拟机实现拨号上网同时内网通信
  2. python用raise手动抛出异常
  3. lt;备份gt;10月18日 DNS
  4. python 的基础 学习 第七天 is id 编码的补充
  5. 使用azkaban调度spark任务
  6. 33. Search in Rotated Sorted Array
  7. GM6 1.38.1 start up debug - share memory
  8. [蓝桥杯][2014年第五届真题]排列序数(思维)
  9. css样式有行内式还有什么,在行内式CSS样式中,属性和值的书写规范与CSS样式规则不相同...
  10. 天呐,你竟然还在用 try–catch-finally
  11. Many to many example - 1 of 4
  12. objective-c和java下解析对象类型和数组类型JSON字符串
  13. Apache虚拟机和访问控制
  14. ehcache 在web项目中使用
  15. UE4学习笔记(3)——World Composition无缝拼接地图实现
  16. 扒一个超棒的stm32的开源usb-can项目,canable及PCAN固件
  17. 产品初探(一):面试经验记录
  18. Echarts 自定义、覆盖legend点击事件、禁用legend默认的点击行为的实现
  19. 「 LaTex 」使用多级标题
  20. 机器学习中的特征重要性 Feature Importance

热门文章

  1. Dlog 替代 NSLog
  2. js使用window.print()实现打印功能
  3. ALI Flutter进阶笔记,移动手机app开发
  4. 创建学院表 学生表 教师表 课程表 选课记录表
  5. 浏览器兼容性问题2(持续更新中)
  6. error Unable to authenticate, need: BASIC realm=“Sonatype Nexus Repository Manager“
  7. 学生党如何拿到阿里技术offer:《阿里实习生面试经验(成功)》
  8. 电脑密码忘记了怎么办?不用U盘,轻松开启电脑
  9. 外贸站要做外链工作吗?外贸站外推广工作内容
  10. JavaWeb 文件上传和下载