![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
各种博弈
薄层
努力就有收获~
展开
-
LightOJ-1253 Misere Nim(Nim求解不正常的博弈)
Alice and Bob are playing game of Misère Nim. Misère Nim is a game playing on k piles of stones, each pile containing one or more stones. The players alternate turns and in each turn a player can select one of the piles and can remove as many stones from t原创 2017-10-21 21:20:34 · 616 阅读 · 0 评论 -
HDU-4664 Triangulation(博弈SG打表+类似凸包性质)
There are n points in a plane, and they form a convex set. No, you are wrong. This is not a computational geometry problem. Carol and Dave are playing a game with this points. (Why not Alice and Bob? Well, perhaps they are bored. ) Starting from no edges原创 2017-11-30 17:55:56 · 327 阅读 · 0 评论 -
HDU-5795 A Simple Nim(SG函数打表找规律)
题意:两人以最优策略对n堆物品进行操作,不能操作者输.1.从同一堆中取任意个(不为零).2.把一堆分成任意三堆(任一堆非空).思路:通过SG函数打表找规律,当对一堆物品进行分成三堆时,几种分法就是几种能到达的状态,而一种分法的SG值则是对该分法得到3份个数,对它们的SG值进行抑或起来就是该分法的SG值。最终可以找到规律,SG值当对8取余为7时,SG[x] = x原创 2017-03-21 15:36:33 · 382 阅读 · 0 评论 -
HDU-1848--博弈SG函数模板题
这篇文章写的很好,值得转发。首先定义mex(minimal excludant)运算,这是施加于一个集合的运算,表示最小的不属于这个集合的非负整数。例如mex{0,1,2,4}=3、mex{2,3,5}=0、mex{}=0。对于一个给定的有向无环图,定义关于图的每个顶点的Sprague-Grundy函数g如下:g(x)=mex{ g(y) | y是x的后继 },转载 2017-03-21 16:19:41 · 527 阅读 · 0 评论 -
HDU 1079 Calendar Game(NP状态交替)
It's a easy Game Theory......网上是这么说的,思想到时不难,但操作起来自己遇到些麻烦。作为一只博弈论入门级别弱脊,于是来写一篇题解总结一下吧,虽然是自己模拟出来的,但中间还是遇到了一丝丝麻烦。大家都知道,所有的后继状态是N状态的某个状态叫做P状态,后继状态中存在一个或多个状态为P状态的某个状态叫做P状态,哎,当时写的时候不知道咋想的,写×了,于是WA了好多次,但今天原创 2017-03-24 14:33:29 · 419 阅读 · 0 评论 -
从SG函数浅谈解决博弈问题的通法
基于笔者之前对于几种二元零和博弈游戏的介绍,这里将其思想进行简单的提炼,并引出解决这类二元零和博弈游戏的强大工具——SG函数。先来了解一下零和思维,"竞争者此长彼消,胜者之所得加败者之所失等于零”。所谓零和,是博弈论里的一个概念,意思是双方博弈,一方得益必然意味着另一方吃亏,一方得益多少,另一方就吃亏多少。之所以称为“零和”,是因为将胜负双方的“得”与“失”相加,总数为零。转载 2017-03-26 23:41:40 · 465 阅读 · 0 评论 -
HDU 1729 Stone Game
一道SG函数+找规律的博弈。思路:先选个稍大点的数把各点SG状态打印出来,然后找规律,这题很容易看出,当到达第一个满足i*i+i >= s的点,它的SG值为(s-i),这样就可以很快判断出c >= k(k为第一个满足i*i>=s的点)时的SG值。当c = k时直接break,因为>=k时的SG值都是很大且递减的,知道最后SG[s]为0,在找规律时也很容易可看出,第一个不满足i*i+i >=原创 2017-04-11 14:47:07 · 302 阅读 · 0 评论 -
蓝桥杯 高僧斗法(nim博弈)
只为写一篇与网上博文不相同的代码,我的代码的主要思想是:移动某个位置的石子(小和尚),奇数位向前移动会减少当前一组的nim值,偶数位向前移动会增加当前组的nim值。因此使nim和为0的情况(因为可使某组nim增加或减少)不仅仅只有移动奇数堆,所以不是阶梯博弈。#include #include #include #include using namespace std;int jk[原创 2017-04-19 12:21:11 · 800 阅读 · 2 评论 -
ZOJ-3964 2017年浙大省赛G题博弈
先记录下心情,其实在看大佬题解前,自己已经基本yy出来了,但有一两个点没处理好,就只能放弃,亟待加油啊~本题思路:特判bi为1或者为2时的情况,① 当bi = 1 && ai == 1时,此时这堆石子会被看作普通堆,因为两个人的合法操作是一样的;② 当除第一种情况之外的bi == 1 || bi == 2的堆数大于1堆时,Bob必胜,因为此时Alice的操作是受一堆以上的堆约束的,原创 2017-04-29 23:59:48 · 673 阅读 · 0 评论 -
HDU-5973 Game of Taking Stones(大数+二分求精度)
题意:单纯的威佐夫博弈,不过数据范围增加到10^100,所以要用Java大数,所以当数一大,黄金分割数(1+√5)/2.0的精度就很重要了,而黄金分割数的精度又在于√5的精度,所以需要用到二分法求√5到一定精度。import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;原创 2017-05-02 00:31:43 · 584 阅读 · 0 评论 -
SDUT 3893 威佐夫+nim博弈(第八届山东ACM省赛A题)
Return of the NimTime Limit: 1000MS Memory Limit: 65536KBSubmit StatisticProblem DescriptionSherlock and Watson are playing the following modified version of Nim game:There are n p原创 2017-05-10 12:45:24 · 443 阅读 · 0 评论 -
SHU-丢史蒂芬妮(博弈NP状态交替)
有一天,空和白很无聊,决定玩盛大游戏,考虑到两个人玩,他们随便掏了一个游戏出来:在一个n∗m 的棋盘上,首先把史蒂芬妮·多拉放在左上角(1,1) 的位置。每次一个人可以将她往下,往右,往右下丢一格。当前回合,谁不能丢史蒂芬妮,谁就输了。(注意,不可以把活人丢出棋盘啦!)游戏总是空先手。白说,这是一个垃圾游戏!我们每次把史蒂芬妮丢素数个位置吧!(换句话说,每次丢2 或3 或5 或7 或…格)空答应了。我们都知道,空和白都很聪明,不管哪方存在一个可以必胜的最优策略,都会按照最优策略保证胜利。玩了一局原创 2017-07-10 10:25:56 · 619 阅读 · 0 评论 -
LightOJ-1296 Again Stone Game(SG打表找规律)
Alice and Bob are playing a stone game. Initially there are n piles of stones and each pile contains some stone. Alice stars the game and they alternate moves. In each move, a player has to select any pile and should remove at least one and no more than ha原创 2017-07-29 11:14:23 · 319 阅读 · 0 评论 -
HDU-4315 Climbing the Hill(阶梯博弈变形)
题意:在山上有n个人,每个人编号是1~n,这些位置只能同时被一个人占据,但是山顶可以同时被多个人占据,距离山顶第k近的是King,现在Alice和Bob开始向上送人,条件是不能跨越前面最近的人,问在Alice先手,双方最优的条件下谁能把King送到山顶获胜。思路:一道阶梯博弈变形的题,POJ-1704是一道朴素的阶梯博弈题目,但是这题与之有区别:每个点都可以移动到山顶,如果没这个条件再原创 2017-08-09 11:52:05 · 591 阅读 · 0 评论 -
HDU-5724 Chess(SG函数+状压)
Alice and Bob are playing a special chess game on an n × 20 chessboard. There are several chesses on the chessboard. They can move one chess in one turn. If there are no other chesses on the right adjacent block of the moved chess, move the chess to its ri原创 2017-08-09 15:21:24 · 343 阅读 · 0 评论 -
CodeForces-731E Funny Game(DP+Games)
Once upon a time Petya and Gena gathered after another programming competition and decided to play some game. As they consider most modern games to be boring, they always try to invent their own games. They have only stickers and markers, but that won't st原创 2017-08-13 12:30:36 · 370 阅读 · 0 评论 -
HDU-5754 Life Winner Bo(混合博弈)
Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×MN×M.The top left corner is numbered(1,1)(1,1) and the lower right corner is numberd (N,M)(N,M). For each game,Bo and G take turns moving a c原创 2017-09-05 14:57:40 · 279 阅读 · 0 评论 -
HDU-4111 Alice and Bob(博弈 + 记忆化搜索)
Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they always find the best strategy, and that's why they feel bored again and again. They just invented a new game, as they usuall原创 2017-12-20 17:19:38 · 515 阅读 · 0 评论