Codeforces 549C The Game Of Parity(博弈)
Solution:
这个题只需要分类讨论就可以解决。
先分别统计奇数和偶数的个数。
然后判断谁走最后一步,如果走最后一步时候同时有偶数和奇数,那么走最后一步的赢。如果没有呢,就看剩下的是奇数还是偶数,是偶数不用说,是奇数看剩奇数个还是偶数个。
针对这几种情况讨论一下就可以。
#include <bits/stdc++.h> using namespace std;
int n, k, o, e;
int main()
{
cin >> n >> k;
for( int i = , x; i <= n; ++i ) {
cin >> x;
o += x & ;
e += !( x & );
}
int sta = o & ;
int t = n - k;
if( t > ) {
if( t & ) {
sta = ;
if( ( min( o, e ) > t / ) || ( o > e && k & ) ) sta = ;
} else {
sta = ;
if( ( min( o, e ) > (t+) / ) || ( o > e && !( k & ) ) || ( e > o ) ) sta = ;
}
}
puts( sta ? "Stannis" : "Daenerys" );
}
Codeforces 549C The Game Of Parity(博弈)的更多相关文章
- Codeforces 549C The Game Of Parity【博弈】
C语言纠错大赛的一道题,正好拿来补博弈~~ 给的代码写的略奇葩..不过还是直接在上面改了.. 题目链接: http://codeforces.com/problemset/problem/549/C ...
- Codeforces 549C. The Game Of Parity[博弈论]
C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 549C(博弈)
C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces 979E Kuro and Topological Parity - 动态规划 - 组合数学
题目传送门 传送点 题目大意 给定$n$个标号依次为$1, 2, \cdots, n$的点,其中一些点被染成一些颜色,剩下的点没有染色.你需要添加一些有向边并将剩下的点染色,满足有向边从编号小的一端指 ...
- Looksery Cup 2015 C. The Game Of Parity —— 博弈
题目链接:http://codeforces.com/problemset/problem/549/C C. The Game Of Parity time limit per test 1 seco ...
- Codeforces 538E Demiurges Play Again(博弈DP)
http://codeforces.com/problemset/problem/538/E 题目大意: 给出一棵树,叶子节点上都有一个值,从1-m.有两个人交替从根选择道路,先手希望到达的叶子节点尽 ...
- Codeforces 979E Kuro and Topological Parity(dp)
题面传送门 题意:有 \(n\) 个点,每个点要么被涂黑,要么被涂白,要么没有颜色. 现在你要: 给没有颜色的点图上颜色(黑色或白色) 在这 \(n\) 个点中连若干条有向边,可以不连通.但是只能从编 ...
- CodeForces 513A Game (水题,博弈)
题意:两个人有n1,n2个球,然后分别最多拿出 k1,k2个球,然后扔掉,谁先拿完谁输. 析:很简单么,每人都足够聪明,就每次扔一个好了,那么,谁的球多,谁就能赢呗,如果相等,那么第一个扔的输. 代码 ...
- Codeforces 768 E. Game of Stones 博弈DP
E. Game of Stones Sam has been teaching Jon the Game of Stones to sharpen his mind and help him de ...
随机推荐
- Installing Ubuntu on a Pre-Installed Windows 8 (64-bit) System (UEFI Supported)
http://askubuntu.com/questions/221835/installing-ubuntu-on-a-pre-installed-windows-8-64-bit-system-u ...
- 小Q书桌的下载、安装和使用
最近,无意之间,在某大牛电脑里,使用到了这款软件.感谢! 确实,挺实用和方便的,强烈推荐!!! 1. 下载 http://qdesk.qq.com/ 2. 安装 3. 使用 多么方便啊!
- 【转】谁说Vim不是IDE?(一)
谁说Vim不是IDE?(一) 话说操作系统.编程语言和编辑器似乎是程序员永恒的吐槽话题,技术发展了几十年,大家讨论起这几个“之争”还是充满愤怒.津津乐道.有人描述过Emacs和VI程序员,大家沿着 ...
- python手记(26)
#!/usr/bin/env python import cv2 import sys fn="test2.jpg" if __name__ == '__main__': prin ...
- 是否以某字符串结尾 是否以某字符串开始 是否是整数 裁减字符串空格 是否是浮点数 是否所有字符为数字类型 是否为空 是否是EMAIL 是否是电话号码 身份证号码验证-支持新的带x身份证 日期验证
/* 1.是否以某字符串结尾 endsWith(theStr,endStr) @param theStr:要判断的字符串 @param endStr:以此字符串结尾 @return boolean; ...
- Kerberos验证过程
参考文献: How the Kerberos Version 5 Authentication Protocol Works: Logon and Authentication SQL Kerbero ...
- 深入了解当前ETL中用到的一些基本技术
数据集成是把不同来源.格式和特点的数据在逻辑上或物理上有机地集中,从而为企业提供全面的数据共享,是企业商务智能.数据仓库系统的重要组成部分.ETL是企业数据集成的概念出发,简要分析了当前ETL中用到的 ...
- 数位DP问题整理(一)
第一题:Amount of degrees (ural 1057) 题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1057 题意:[x,y ...
- Bulk Insert命令具体
Bulk Insert命令具体 BULK INSERT以用户指定的格式复制一个数据文件至数据库表或视图中. 语法: BULK INSERT [ [ 'database_name'.][ 'owner' ...
- C# StringExt 字符串扩展
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...