HDU 5754 Life Winner Bo 组合博弈】的更多相关文章

Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner is numberd (N,M). For each game…
Life Winner Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower r…
题目:传送门 题意:一个国际象棋棋盘,有四种棋子,从(n,m)走到(1,1),走到(1,1)的人赢,先手赢输出B,后手赢输出G,平局输出D. 题解:先把从(n,m)走到(1,1)看做是从(1,1)走到(n,m). 四种棋子的规则如下: 1.王(King):横.竖.斜都可以走,每次限走一格 2.车(Rook):横.竖均可走,不能斜走,格数不受限制,除王车易位的情况下,平时不能越子 3.马(Knight):每步棋先横走或竖走一格,再斜走一格(或者横两格竖一格,竖两格横一格),可以越子 4.后(Que…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5754 给你四种棋子,棋子一开始在(1,1)点,两个人B和G轮流按每种棋子的规则挪动棋子,棋子只能往右下方移动,谁最后先挪动棋子到(n,m)位置,谁就胜利.要是两个人都不可能赢,就输出D. king的情况在纸上模拟了一下,感觉就是当n*m为奇数时先手输,否则就赢. rook的情况比较简单,相当于在两堆石子中取石子,只能在一堆中取.当n等于m时,先手必败,因为先手怎么取,后手都会跟上取 使得两堆石子相同…
http://acm.hdu.edu.cn/showproblem.php?pid=5754 题意: 给一个国际象棋的棋盘,起点为(1,1),终点为(n,m),现在每个棋子只能往右下方走,并且有4种不同的棋子,棋子的走法与国际象棋走法一致.问最后谁能取得胜利. 思路: 首先推荐一个博客http://www.matrix67.com/blog/archives/6784,这里面对这问题有很好的讲解. 我还是简单解释一下: ①king: 国王每次只能横.竖.斜走一格,这个很好分析,(x,y)如果连个…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5754 题目大意: 4种棋子,象棋中的 1王,2车,3马,4后,选其一,B和G轮流走,不能往左上走,一开始棋子在(1,1),谁先走到(n,m)谁赢,无法走动算平局D. (n,m<=1000,case<=1000) 题目思路: [博弈论] 这题博弈论.怎样都输为必败,只能走到必败的为必胜. 王:(王可以横竖斜走一格)如果n个m均为奇数先手必败,否则必胜. 从3x3格子看,当n和m均为奇数时先手必败,…
四种棋子实质上都是一样的思路: 如果某位置的棋子,它下一步可以走到的位置中 能找到有后手胜的位置,那么该位置先手必胜. 如果某位置的棋子,它下一步可以走到的位置中 全是先手胜,那么该位置后手必胜. 其余三种都用如上思路打表即可,但要注意马的情况(因为马可能有些位置走不到终点): 如果该位置走过去的两个位置都是平局的,那么该位置也是平局. 如果该位置走过去的两个位置都是先手胜,那么该位置后手胜. 如果该位置走过去的两个位置中有至少一个位置是后手胜,那么该位置先手胜. 其余情况,均为平局. #pra…
对于king:我是套了一个表. 如果起点是P的话,则是后手赢,否则前手赢. 车:也是画图推出来的. 马:也是推出来的,情况如图咯. 对于后:比赛时竟然推错了.QAQ最后看了题解:是个威佐夫博奕.(2,3),(4,6),(5,8)……(ak,ak+k),ak是当前没有出现过的最小正整数.k就是两个坐标的差值,从1,2,3,4…… #include <iostream> #include <cstdio> #include <algorithm> #include <…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×M.The top left corner is numbered(1,1) and the lower right corner…
题目链接: Life Winner Bo Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others) Problem Description Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard is N×M.The…
Life Winner Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1019    Accepted Submission(s): 373 Problem Description Bo is a "Life Winner".He likes playing chessboard games with his gir…
题目链接:hdu_5754_Life Winner Bo 题意: 一个棋盘,有国王,车,马,皇后四种棋子,bo先手,都最优策略,问你赢的人,如果双方都不能赢就输出D 题解: 全部都可以直接推公式, 这里我推出前两种比较简单的,后面的模拟打个表就行了 #include<bits/stdc++.h> #define mst(a,b) memset(a,b,sizeof(a)) #define F(i,a,b) for(int i=a;i<=b;++i) using namespace std…
给定一个n*m的矩阵,有四种棋子(国际象棋的王,王后,骑士,车).起点在(1,1)先走到(n,m)获胜. 分析:车是nim博弈.王后是威佐夫博弈.王和骑士写两个1000*1000的预处理即可. hdu5754Life Winner Bo 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ; int f[N][N],…
题目链接:hdu_5724_Chess 题意: 给你一个n行20列的棋盘,棋盘里面有些棋子,每个棋子每次只能往右走一步,如果右边有棋子,可以跳过去,前提是最右边有格子,如果当前选手走到没有棋子可以走了,那么就算输,问你先手是否会赢 题解: 一看就知道是组合博弈的问题,关键在于如果求SG值,这里要把一行看成一个状态,然后根据SG值的定义去求,如果不知道SG的求法,那去找度娘吧.预处理出一行所有状态的SG,然后对每一行异或一下就行了. #include<cstdio> #include<cs…
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…
Bo is a "Life Winner".He likes playing chessboard games with his girlfriend G. The size of the chessboard ,)(,) and the lower right corner is numberd (N,M)(N,M). For each game,Bo and G take turns moving a chesspiece(Bo first).At first,the chessp…
题目大意:输入3个整数m,n,p,分别表示3堆石头中的石头个数 解题思路: 1)斐波那契数列的第16个数fib[16] == 1597 2)(sg[m]^sg[n]^sg[p])   .一定要加括号,否则会WA 代码如下: /* * 1848_1.cpp * * Created on: 2013年9月1日 * Author: Administrator */ #include <iostream> using namespace std; const int maxn = 1001; int…
题目链接: 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…
A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns picking candies from n heaps,the player who picks the last one will win the game.On each turn they can pick any number of candies which come from the…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 题意:Tang 和 Jiang 玩一个游戏,轮流写下一个数,Tang先手,第一次Tang只能写[1,k]之间的数,X表示上一个人写的数,Y表示下一个人写的数,每次必须满足 1<=Y-X<=k,直到有一个人写下的数不小于n,写下那个数的人失败,游戏结束,输出胜利的人. 分析:可以看做是取石子游戏,有一堆n-1个的石子,两个人轮流去石子,每次最多能去k个,如果没有石子可取则输,这就将问题转化为巴…
Be the Winner Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4939    Accepted Submission(s): 2724 Problem Description Let's consider m apples divided into n groups. Each group contains no more…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4764 Problem Description Tang and Jiang are good friends. To decide whose treat it is for dinner, they are playing a game. Specifically, Tang and Jiang will alternatively write numbers (integers) on a wh…
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天这篇是算法与数据结构专题的第27篇文章,我们继续深入博弈论问题.今天我们要介绍博弈论当中非常重要的一个定理和函数,通过它我们可以解决许多看起来杂乱无章的博弈问题,使得我们可以轻松地解决一大类博弈问题. 有了SG函数和SG定理,我们不再是单纯地通过构思.分析和找规律去解决问题了.并且我们之前学过的巴什博奕.威佐夫博弈以及Nim博弈都可以使用SG函数来解决,相当于我们找到了这一大类问题的通解.下面,我们来看几个基本定理和基本概念. 基本…
先在每堆中进行巴什博弈,然后尼姆 #include<stdio.h> int main() { int T; int i,n; int ans,m,l; scanf("%d",&T); while(T--) { scanf("%d",&n); ans=; ;i<=n;i++) { scanf("%d%d",&m,&l); ans=ans^(m%(l+)); } ) printf("Yes…
Climbing the Hill Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Alice and Bob are playing a game called "Climbing the Hill". The game board consists of cells arranged vertically, as the…
KK's Number 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/K Description Our lovely KK has a funny mathematical game:This game requires two people,There are numbers,every time KK will take the numbers,first.Every time you can take any num…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4602 我们可以特判出n<= k的情况. 对于1<= k<n,我们可以等效为n个点排成一列,并取出其中的连续k个点.下面分两种情况考虑: 第一种情况,被选出的不包含端点,那么有(n–k−1)种情况完成上述操作,剩下未被圈的点之间还有(n–k−2)个位置,可以在每个位置断开,所以共2^(n−k−2) ∗(n−k−1)种方法. 第二种情况,即被选出的包含端点,那么有2种情况,并且剩余共(n–k−1…
2048 Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 840    Accepted Submission(s): 199 Problem Description Teacher Mai is addicted to game 2048. But finally he finds it's too hard to get 2048.…
题目链接:https://cn.vjudge.net/problem/HDU-1079 题目: Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they played the Calendar Game, in celebration of this contest. This game consists of the dates from January 1…
Fliping game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 307    Accepted Submission(s): 220 Problem Description Alice and Bob are playing a kind of special game on an N*M board (N rows, M co…