HDU 2509 Be the Winner nim博弈变形】的更多相关文章

Be the Winner Problem Description   Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.For example "@@@" can be turned into &q…
题目大意:输入一个整数n,表示火柴堆数(原题其实指的是苹果堆数,但是为了尽量与模板保持一致,所以在这里理解为火柴堆数....其实理解为什么都没关系, 重要的是,理解就行....).在接下来的一行中,有n个数字,表示每个火柴堆的火柴根数. 解题思路:还是去火柴棒的问题 详细的说明请参考上一篇博客 代码如下: /* * 2509_1.cpp * * Created on: 2013年9月1日 * Author: Administrator */ #include <iostream> using…
HDU 2897 邂逅明下 ( bash 博弈变形 题目大意 有三个数字n,p,q,表示一堆硬币一共有n枚,从这个硬币堆里取硬币,一次最少取p枚,最多q枚,如果剩下少于p枚就要一次取完.两人轮流取,直到堆里的硬币取完,最后一次取硬币的算输. 解题思路 若 n == k * (p + q), 则 A 必胜 第一次 A 取 p 个, 之后每次 B 取 x 个时, A 取 (p + q - x) 个, 则最后当 B 面对有 p 个硬币的时候, 必输. 若 n == k * (p + q) + left…
1.HDU 2509  2.题意:n堆苹果,两个人轮流,每次从一堆中取连续的多个,至少取一个,最后取光者败. 3.总结:Nim博弈的变形,还是不知道怎么分析,,,,看了大牛的博客. 传送门 首先给出结论:先手胜当且仅当(1)所有堆石子数都为1且游戏的SG值为0,(2)存在某堆石子数大于1且游戏的SG值不为0.证明:(1)若所有堆石子数都为1且SG值为0,则共有偶数堆石子,故先手胜.(2) i)只有一堆石子数大于1时,我们总可以对该堆石子操作,使操作后石子堆数为奇数且所有堆得石子数均为1 ii)有…
Problem Description Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. And so o…
1.HDU 1907 2.题意:n堆糖,两人轮流,每次从任意一堆中至少取一个,最后取光者输. 3.总结:有点变形的Nim,还是不太明白,盗用一下学长的分析吧 传送门 分析:经典的Nim博弈的一点变形.设糖果数为1的叫孤独堆,糖果数大于1的叫充裕堆,设状态S0:a1^a2^..an!=0&&充裕堆=0,则先手必败(奇数个为1的堆,先手必败).S1:充裕堆=1,则先手必胜(若剩下的n-1个孤独堆个数为奇数个,那么将那个充裕堆全部拿掉,否则将那个充裕堆拿得只剩一个,这样的话先手必胜).T0:a1…
题目链接: PKU:http://poj.org/problem? id=3480 HDU:http://acm.hdu.edu.cn/showproblem.php? pid=1907 Description Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to…
Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14312   Accepted: 4840 Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, ..…
博弈的题目,打表找规律还是相当有用的一个技巧. 这个游戏在原始的Nim游戏基础上又新加了一个操作,就是游戏者可以将一堆分成两堆. 这个SG函数值是多少并不明显,还是用记忆化搜索的方式打个表,规律就相当显然了. #include <cstdio> #include <cstring> ; ]; ]; int mex(int v) { ) return sg[v]; memset(vis, false, sizeof(vis)); ; i < v; i++) vis[mex(i)…
John Problem Description   Little John is playing very funny game with his younger brother. There is one big box filled with M&Ms of different colors. At first John has to eat several M&Ms of the same color. Then his opponent has to make a turn. A…