Codeforces Round#429 B-Godesend
来源:互联网 发布:python 微信报警接口 编辑:程序博客网 时间:2024/06/07 02:41
题意&分析:
题目传送门
First选手可以取走数组中一段和为奇数的子串,Second取走的是和为偶数的子串,取走后剩余部分合并成新的数组。谁不能再取则输。
若全部和为奇数,First直接获胜。
若为偶数,只需要判断数组中是否有奇数,若有,则First取走后剩余部分和任为奇数,取走一段偶数部分的和,剩余依然是奇数。
代码如下:
#include <bits/stdc++.h>#define INF 0x3f3f3f3f#define TEST cout<<"stop here"<<endl using namespace std;typedef long long ll;const ll mod = 1e9 + 7;int main(){ std::ios::sync_with_stdio(false); std::cin.tie(0); int n; while(cin>>n){ int ans = 0,flag = 0; for(int i=0;i<n;i++){ ll x; cin>>x; if(x%2==1){ flag = 1; ans++; } } if(!ans && !flag) cout<< "Second" <<endl; else cout<< "First" <<endl; } return 0;}
阅读全文
0 0
- Codeforces Round#429 B-Godesend
- Codeforces Round #429 (Div2) B
- Codeforces Round #429 (Div. 2):B. Godsend
- Codeforces Round #429 (Div. 2) | B. Godsend
- Codeforces Round #136 B
- Codeforces Round #239 --B
- Codeforces Round #300 B
- codeforces round # 412B
- Codeforces Round #425 B
- Codeforces Round #438 B
- Codeforces Round #439 B
- Codeforces Round #439 B
- Codeforces Round #397 B
- Codeforces Beta Round #60-B
- Codeforces Beta Round #2 B
- codeforces round 176Div1 B
- codeforces div2 round#231 B
- codeforces div2 round#230 B
- Hadoop之Java通过URL操作HDFS-yellowcong
- CF --- 831C Jury Marks 【思维】
- 银行电子回单打印中Base64使用。
- 714A. Meeting of Old Friends
- 常用github命令
- Codeforces Round#429 B-Godesend
- PC-Lint代码静态检查之Info 701: Shift left of signed quantity (int)
- HDU-2147-kiki's game 【巴什博弈】
- 如何使用Swiper在同一个页面上多个轮播组件
- squid高速缓存服务器的的介绍和配置
- 关于Visual Studio订阅(原MSDN订阅)中无法激活Office 365权益的解决方法(仅适用于MVP)
- VC工程中的.rc文件和.rc2文件的区别
- VMware下创建Ubuntu教程
- Python 面向对象(初级篇)