URAL 2068 Game of Nuts (博弈)
题意:给定 n 堆石子,每次一个人把它们分成三堆都是奇数的,谁先不能分,谁输。
析:因为每堆都是奇数,那么最后肯定都是要分成1的,那么就把不是1的全加和,然后判断奇偶就OK了。
代码如下:
- #pragma comment(linker, "/STACK:1024000000,1024000000")
- #include <cstdio>
- #include <string>
- #include <cstdlib>
- #include <cmath>
- #include <iostream>
- #include <cstring>
- #include <set>
- #include <queue>
- #include <algorithm>
- #include <vector>
- #include <map>
- #include <cctype>
- #include <cmath>
- #include <stack>
- #define frer freopen("in.txt", "r", stdin)
- #define frew freopen("out.txt", "w", stdout)
- using namespace std;
- typedef long long LL;
- typedef pair<int, int> P;
- const int INF = 0x3f3f3f3f;
- const double inf = 0x3f3f3f3f3f3f;
- const double PI = acos(-1.0);
- const double eps = 1e-8;
- const int maxn = 8;
- const int mod = 1e9 + 7;
- const char *mark = "+-*";
- const int dr[] = {-1, 0, 1, 0};
- const int dc[] = {0, 1, 0, -1};
- int n, m;
- const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
- inline int Min(int a, int b){ return a < b ? a : b; }
- inline int Max(int a, int b){ return a > b ? a : b; }
- inline LL Min(LL a, LL b){ return a < b ? a : b; }
- inline LL Max(LL a, LL b){ return a > b ? a : b; }
- inline bool is_in(int r, int c){
- return r >= 0 && r < n && c >= 0 && c < m;
- }
- int main(){
- while(scanf("%d", &n) == 1){
- int ans = 0;
- for(int i = 0; i < n; ++i){
- scanf("%d", &m);
- if(m > 2)
- ans += m/2;
- }
- if(ans % 2 == 0) puts("Stannis");
- else puts("Daenerys");
- }
- return 0;
- }
URAL 2068 Game of Nuts (博弈)的更多相关文章
- ural 2068. Game of Nuts
2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...
- Timus 2068. Game of Nuts 解题报告
1.题目描述: 2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still i ...
- POJ 2068 Nim#双人dp博弈
http://poj.org/problem?id=2068 #include<iostream> #include<cstdio> #include<cstring&g ...
- URAL 1180. Stone Game (博弈 + 规律)
1180. Stone Game Time limit: 1.0 second Memory limit: 64 MB Two Nikifors play a funny game. There is ...
- POJ 2068 NIm (dp博弈,每个人都有特定的取最大值)
题目大意: 有2n个人,从0开始编号,按编号奇偶分为两队,循环轮流取一堆有m个石子的石堆,偶数队先手,每个人至少取1个,至多取w[i]个,取走最后一个石子的队伍输.问偶数队是否能赢. 分析: 题目数据 ...
- poj 2068 Nim(博弈dp)
Nim Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1403 Accepted: 791 Description Le ...
- URAL - 1397:Points Game (博弈,贪心)
Two students are playing the following game. There are 2· n points on the plane, given with their co ...
- Ural State University Internal Contest October'2000 Junior Session
POJ 上的一套水题,哈哈~~~,最后一题很恶心,不想写了~~~ Rope Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7 ...
- URAL2104. Game with a Strip(博弈)
There is a strip 1 × n with two sides. Each square of the strip (their total amount is 2n, n squares ...
随机推荐
- MVC+Ef项目(2) 如何更改项目的生成顺序;数据库访问层Repository仓储层的实现
我们现在先来看看数据库的生成顺序 居然是 Idal层排在第一,而 web层在第二,model层反而在第三 了 我们需要把 coomon 公用层放在第一,Model层放在第二,接下来是 Idal ...
- mac下编译optool方法
参考地址:http://www.mopsled.com/2016/build-optool-osx/ 1.git clone https://github.com/alexzielenski/opto ...
- 2015-10-09 Fri 晴 加快进度看书
最近老感觉每天不够用,每天7点起来,吃饭完了8点开始看书,不知道是我看书太慢了还是时间过得真的很快,不知不觉中午就到了.而这个时候我才看2章的内容,下午能多看3章内容.一本书也就一天的时候,而我现在还 ...
- 《Unix网络编程》卷2 读书笔记 第1章-简介
1. 概述 2. 进程.线程与信息共享 Unix进程间的信息共享有多种方式:注意下图中内核的位置 左边的两个进程共享存留于文件系统中某个文件上的某些信息.为访问这些信息,每个进程都得穿越内核. 中 ...
- Java自增原子性问题(测试Volatile、AtomicInteger)
这是美团一面面试官的一个问题,后来发现这是一道面试常见题,怪自己没有准备充分:i++;在多线程环境下是否存在问题?当时回答存在,接着问,那怎么解决?...好吧,我说加锁或者synchronized同步 ...
- dubbo-admin在jdk 1.8上部署出错问题
今天在linux上部署dubbo-admin-2.5.4,一直报错: ERROR context.ContextLoader - Context initialization failedorg.sp ...
- c# datagridview表格控件常用操作
1) 行右键菜单 private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { ...
- getHibernateTemplate() 一直报NullPointerException 错误
原来是调用方法有误正确调用方法: ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContex ...
- 嵌入式 Linux下编译并使用curl静态库
#x86 ./configure --disable-shared --enable-static --disable-ftp --disable-ipv6 --disable-rtsp --disa ...
- Multi-Device Hybrid Apps for Visual Studio CTP2.0
http://msdn.microsoft.com/en-us/library/dn771545.aspx http://www.microsoft.com/en-us/download/detail ...