博弈
0x3f3f3f3f
这个作者很懒,什么都没留下…
展开
-
Nim博弈讲解篇
Nim游戏的概述: 还记得这个游戏吗? 给出n列珍珠,两人轮流取珍珠,每次在某一列中取至少1颗珍珠,但不能在两列中取。最后拿光珍珠的人输。 后来,在一份资料上看到,这种游戏称为“拈(Nim)”。据说,它源自中国,经由被贩卖到美洲的奴工们外传。辛苦的工人们,在工作闲暇之余,用石头玩游戏以排遣寂寞。后来流传到高级人士,则用便士(Pennies),在酒吧柜台上玩。 最有名的玩法,是把十二枚便转载 2016-12-02 12:06:38 · 341 阅读 · 0 评论 -
POJ 2234 —— Matches Game 入门水题
原题:http://poj.org/problem?id=2234 #include using namespace std; int m; int main(){ while(cin>>m){ int x = 0; while(m--){ int y; cin>>y; x =原创 2016-12-02 12:08:10 · 288 阅读 · 0 评论 -
HDU 1849 —— Rabbit and Grass
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1849 思路:以两个棋子为例,如果当前它们在不同的位置,那么先手只需要将两个棋子变成在同一个位置,就能获胜,与Nim博弈类似; #include using namespace std; int m; int main(){ while(cin>>m){ if(m ==原创 2016-12-02 12:18:27 · 349 阅读 · 0 评论 -
HDU 1907 —— John
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1907 题意:取法和Nim游戏一样,但是最后拿完的那个人是loser; 思路:需要考虑特殊情况 —— 最开始每堆的个数都为1,这个时候对堆数进行奇偶判断; #include using namespace std; const int maxn = 50; int cas, n; int a[原创 2016-12-02 16:01:53 · 318 阅读 · 0 评论 -
HDU 1527 —— 取石子游戏(入门水题)
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1527 #include #include using namespace std; int a, b; int main(){ while(cin>>a>>b){ int k = abs(a-b); double tmp = (sqrt(5)+1)/2.0原创 2016-12-02 22:30:15 · 386 阅读 · 0 评论 -
HDU 2177 —— 取(2堆)石子游戏
原题:http://acm.hdu.edu.cn/showproblem.php?pid=2177 #include #include using namespace std; int a, b; int main(){ while(cin>>a>>b){ if(a == 0 && b == 0) break; double tmp = (s原创 2016-12-02 23:11:07 · 430 阅读 · 0 评论