![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
博弈
become__better
大胆去问,大胆去做,效率
展开
-
Georgia and Bob POJ-1704(阶梯博弈)
题目地址:http://poj.org/problem?id=1704 当一组内两个石子并在一起,后手必胜,新手如何移动前者,后手就如何移动后者即可,又恢复了状态,直到先手不能移动。 #include <cstdio> #include <iostream> #include <cstring> #include <string> #include ...原创 2019-07-24 20:54:42 · 106 阅读 · 0 评论 -
取(m堆)石子游戏 HDU - 2176(尼姆博奕)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2176 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<stdlib.h> #include<queue> #includ...原创 2019-07-28 10:49:18 · 141 阅读 · 0 评论 -
Public Sale HDU - 2149(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2149 思路:**巴什博弈。**把N元看成n个石子。 当n%(m+1)==0时后手必胜,其他时先手必胜。 在先手能一次取完时,输出n n+1 …m。其他时,先手取完后,让n%(m+1)==0,那么取得个数就是n%(m+1) #include <cstdio> #include <ios...原创 2019-07-28 10:04:09 · 178 阅读 · 0 评论 -
Coin Game HDU - 3951(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3951 题意:两个玩家用一圈N硬币开始游戏。他们轮流从圆圈里取硬币,每次可以取1~k个连续的硬币。 (假设10个硬币从1到10,k等于3,因为1和10是连续的,你可以拿走连续的10、1、2,但是如果2被拿走,你不能拿走1、3、4,因为1和3不是连续的)。拿最后一枚硬币的玩家获胜。 思路:当一次能取完时,...原创 2019-07-28 09:25:30 · 609 阅读 · 0 评论 -
No Gambling HDU - 3863(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3863 思路:先手必胜。 感觉是先手必胜,但又不好证明。搏一搏,摩托变飞机。一交就AC了。 #include <cstdio> #include <iostream> #include <cstring> #include <string> #includ...原创 2019-07-28 09:02:04 · 167 阅读 · 0 评论 -
Euclid's Game HDU - 1525 (博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1525 题意:给你两个数a,b。要求用较大的数减去较小的数的任意倍数,两方轮流操作,出现0的一方获胜。 思路:设较大者为n,较小者为m。当n%m==0时,此时操作者必胜。当n>m但<2m时,只能让n=n-m,没有选择的空间;当n>=2m时,此时操作者也必胜。因为将(n%m与n>=...原创 2019-07-27 19:19:07 · 127 阅读 · 0 评论 -
Calendar Game HDU - 1079(博弈 NP状态定理)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1079 非常经典的 NP状态博弈,有三种方法,记忆化搜索,逆序递推,找规律。 NP状态定理:P是“胜利终止状态”或者它的一切后继状态都是N状态,N是“失败终止状态”或者至少拥有一个后继状态是P状态。 也就是说后继状态为P的一定为N状态,不存在后继状态为N的为P状态。 进行记忆化搜索 将年份-1900...原创 2019-07-27 18:01:15 · 288 阅读 · 0 评论 -
Game HDU - 3389(尼姆博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3389 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int a[10009]; int main() { ...原创 2019-07-27 21:12:46 · 129 阅读 · 0 评论 -
取石子游戏 HDU - 2516(斐波那契博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2516 斐波那契博弈模版题。当n为斐波那契数列时,后手必胜,其他时,先手必胜。 想深入了解,可以看这篇博客:https://blog.csdn.net/dgq8211/article/details/7602807 #include<iostream> #include<algorit...原创 2019-07-27 20:03:53 · 193 阅读 · 0 评论 -
Brave Game HDU - 1846(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1846 巴什博弈的模版题,当n%(m+1)==0时,后手胜;其他时,先手胜。 #include <iostream> #include <cstdio> #include <cmath> using namespace std; int main() { int...原创 2019-07-27 19:45:56 · 93 阅读 · 0 评论 -
Play a game HDU - 1564(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1564 题意:有一个n*n的棋盘,棋子开始在四个边角中的任意一个,棋子可以水平或垂直移动到未访问的格子中,不能移动者失败。 当n为奇数时,后手必胜,n为偶数是先手必胜。 看棋盘除了起点外,能不能分成任意个2 *1的格子。 比如当n=4时与n=3时。 #include<iostream> #...原创 2019-07-27 19:42:40 · 152 阅读 · 0 评论 -
Nim or not Nim? HDU - 3032(SG函数 找规律)
打表代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; #define maxn 156 int s[maxn],sg[maxn]; void init() { memset(sg,0,sizeof...原创 2019-07-22 19:15:28 · 137 阅读 · 0 评论 -
邂逅明下 HDU - 2897(巴什博弈)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2897 题意:一堆有n个石子,一次最少取p个,最多取q个,小于p个则一次性取完,取完者输。 思路:我们可以转化成巴什博弈,变成取完者赢,设m=p+q。那么在不取最后一块的前提下,如果他取了倒数第二块,那么下一个必败,此时(n-1)%m=0,后手必胜,即n%m=1。只要他留给对手的块数小于p,那么他必胜,...原创 2019-07-22 15:20:14 · 164 阅读 · 0 评论 -
Fibonacci again and again HDU 1848(博弈 SG函数)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1848 #include<iostream> #include<algorithm> #include<string> #include<sstream> #include<set> #include<vector> #includ...原创 2019-07-21 20:55:03 · 92 阅读 · 0 评论 -
HDU 1847 Good Luck in CET-4 Everybody! ( 博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1847 #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> using namespace st...原创 2019-03-27 20:21:13 · 85 阅读 · 0 评论 -
A simple stone game HDU - 2486(博弈,k倍动态减法)
思路: 博弈论中的 K倍动态减法游戏,难度较大,参看了好多资料才懵懂! 此题可以看作 Fibonacci 博弈的扩展,建议没弄懂 Fibonacci博弈的先学那个,个人整理 http://blog.csdn.net/tbl_123/article/details/24033245 ; 而说扩展体现在数列不再是Fib数列,是根据 k 的值自行构造的,其它换汤不换药,具体构造方法如下: 这儿方便说明白...转载 2019-07-30 10:46:49 · 264 阅读 · 0 评论 -
A Multiplication Game HDU - 1517(博弈 思维)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1517 题意:一个数p初始为1,每个人可以把P乘以2~~9,当操作完P>=n时,操作者获胜。 思路:当n在9m2m+1–9m+12m先手必胜,当n在9m+12m+1–9m+12m+1后手必胜 2-9时先手必胜,9 10-18时后手必胜。2* 9 19-162时先手必胜,9* 2* 9 163-32...原创 2019-07-30 10:28:40 · 111 阅读 · 0 评论 -
取(2堆)石子游戏 HDU - 2177(威佐夫博奕)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2177 在先手必胜时,有两种情况W>X和W<X W<X W>X #include <iostream> #include <cstdio> #include <cmath> using namespace std; int main()...原创 2019-07-28 11:02:01 · 191 阅读 · 0 评论