Life Winner Bo (博弈论)】的更多相关文章

kind:维持让对手处于(奇数,奇数)的状态,就能赢. rook:维持让对手处于(A,A)相等的状态,就能赢. knight:画图找规律,没有到达终点的就是平局. queen:威佐夫博弈论,终点不一样. #include<bits/stdc++.h> using namespace std; int main() { int T, type, n, m;scanf("%d",&T); while(T --){ scanf("%d%d%d", &a…
对于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 <…
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)先走到(n,m)获胜. 分析:车是nim博弈.王后是威佐夫博弈.王和骑士写两个1000*1000的预处理即可. hdu5754Life Winner Bo 题目连接 #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ; int f[N][N],…
题目链接: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…
题目链接: 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…
题目链接: 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均为奇数时先手必败,…
题目 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…
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…
题目:传送门 题意:一个国际象棋棋盘,有四种棋子,从(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时,先手必败,因为先手怎么取,后手都会跟上取 使得两堆石子相同…
四种棋子实质上都是一样的思路: 如果某位置的棋子,它下一步可以走到的位置中 能找到有后手胜的位置,那么该位置先手必胜. 如果某位置的棋子,它下一步可以走到的位置中 全是先手胜,那么该位置后手必胜. 其余三种都用如上思路打表即可,但要注意马的情况(因为马可能有些位置走不到终点): 如果该位置走过去的两个位置都是平局的,那么该位置也是平局. 如果该位置走过去的两个位置都是先手胜,那么该位置后手胜. 如果该位置走过去的两个位置中有至少一个位置是后手胜,那么该位置先手胜. 其余情况,均为平局. #pra…
http://acm.hdu.edu.cn/showproblem.php?pid=5754 题意: 给一个国际象棋的棋盘,起点为(1,1),终点为(n,m),现在每个棋子只能往右下方走,并且有4种不同的棋子,棋子的走法与国际象棋走法一致.问最后谁能取得胜利. 思路: 首先推荐一个博客http://www.matrix67.com/blog/archives/6784,这里面对这问题有很好的讲解. 我还是简单解释一下: ①king: 国王每次只能横.竖.斜走一格,这个很好分析,(x,y)如果连个…
5/11 2016 Multi-University Training Contest 3官方题解 2016年多校训练第三场 老年选手历险记 暴力 A Sqrt Bo(CYD) 题意:问进行多少次开根号向下取整能使给定的值为1,若为5次以上,则输出TAT: 思路: 有5次这个限制,得知值最大为10的11次方左右,存下后运算即可,注意初始值为0时运算的次数是大于5次的,输出TAT: 代码: #include <bits/stdc++.h> using namespace std; char st…
1001 Sqrt Bo 由于有\(5\)次的这个限制,所以尝试寻找分界点. 很容易发现是\(2^{32}\),所以我们先比较输入的数字是否比这个大,然后再暴力开根. 复杂度是\(O(\log\log n)\). 注意特判\(n=0\)的情况. 1002 Permutation Bo 根据期望的线性性,我们可以分开考虑每个位置对答案的贡献. 可以发现当\(i\)不在两边的时候和两端有六种大小关系,其中有两种是对答案有贡献的. 那么对答案的贡献就是\(\frac{c_i}{3}\). 在两端的话有…
博弈论水题!!! 代码如下: #include<stdio.h> #include<iostream> using namespace std; int main(){ int i,t,n,k,m; while(cin>>n){ m=;t=; ;i<n;i++){ cin>>k; ) t++; m^=k; } &&t>=)||(m!=&&t==)) cout<<"No"<<…
题目链接:https://leetcode.com/problems/predict-the-winner/ 1.暴力递归 当前数组左边界:i,右边界:j: 对于先发者来说,他能取到的最大值是:max(arr[i] + second(arr, i + 1, j), arr[j] + second(arr, i, j - 1)); (arr[i] + 作为后发者,在 i+1 到 j 上取得的值),(arr[j] + 作为后发者,在 i 到 j-1 上取得的值) 中大的一个. 对于后发者来说,他是被…
C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n cities in Westeros. The i-th city is inhabited by ai people. Daenerys and Stannis play the following game:…
http://poj.org/problem?id=2234 博弈论真是博大精深orz 首先我们仔细分析很容易分析出来,当只有一堆的时候,先手必胜:两堆并且相同的时候,先手必败,反之必胜. 根据博弈论的知识(论文 张一飞:<由感性认识到理性认识——透析一类搏弈游戏的解答过程>) 局面可以分解,且结果可以合并. 局面均是先手 当子局面是 胜 和 败,那么局面则为胜 当子局面是 败 和 胜,那么局面则为胜 当子局面是 败 和 败,那么局面则为败 当子局面为 胜 和 胜,那么局面为不确定 而这些性质…
A Lot of Games 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/J Description Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players. Given a group of n non-empty strings. During the game two player…
Meeting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5512 Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two…
朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description B君在围观一群男生和一群女生玩游戏,具体来说游戏是这样的:给出一棵n个节点的树,这棵树的每条边有一个权值,这个权值只可能是0或1. 在一局游戏开始时,会确定一个节点作为根.接下来从女生开始,双方轮流进行 操作.当一方操作时,他们需要先选择一个不为根的点,满足该点到其父亲的边权为1; 然…
博弈论(一):Nim游戏 重点结论:对于一个Nim游戏的局面(a1,a2,...,an),它是P-position当且仅当a1^a2^...^an=0,其中^表示位异或(xor)运算. Nim游戏是博弈论中最经典的模型(之一?),它又有着十分简单的规则和无比优美的结论,由这个游戏开始了解博弈论恐怕是最合适不过了. Nim游戏是组合游戏(Combinatorial Games)的一种,准确来说,属于“Impartial Combinatorial Games”(以下简称ICG).满足以下条件的游戏…
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people are excited, ii and gg are no exception. After watching the game, the two of them also want to play a game. There is now an infinite chessboard with on…
题目:http://community.topcoder.com/stat?c=problem_statement&pm=13204&rd=15857 这道题目须要用到博弈论中的经典理论,Sprague–Grundy theorem,以下将相关理论做一个总结: Impartial Game:公平游戏,两方除了谁先開始游戏外,其余都同样. Nim:一类经典的Impartial Game,非常多游戏都能够等价于Nim. Nimber(Grundy numbers):能够理解为标识一个游戏状态的…
CQRXLB Accepted : 19   Submit : 40 Time Limit : 1000 MS   Memory Limit : 65536 KB CQRXLB Problem Description: CQR and XLB are best friends. One night, they are staring each other and feel boring, and XLB says let's play game! They place n piles of st…
Circles Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5299 Description There are n circles on a infinitely large table.With every two circle, either one contains another or isolates from the other.They are never crossed nor tangent. Alice and…
题目描述 One day, Bessie decides to challenge Farmer John to a game of 'Cow Checkers'. The game is played on an M*N (1 <= M <= 1,000,000; 1 <= N <= 1,000,000) checkerboard that initially contains a single checker piece on the checkboard square coo…