POJ 2484 A Funny Game】的更多相关文章

题目链接:http://poj.org/problem?id=2484 这道题目大意是这样的,有n个硬币围成一圈,两个人轮流开始取硬币(假设他们编号从1到n),可以选择取一枚或者取相邻的两枚(相邻是指他们的编号相邻).在双方都采取最优策略取硬币的情况下,问谁最后会赢. 这道题目我一开始没有什么好的办法,n从1试到7,大致能发现n>=3的时候是Bob赢,否则是Alice赢. 可是为什么这样写正确呢?有没有严格一些的证明呢? 我查阅了许多资料,有了下边的理解,可能不是很准确,望纠正. n<=3的时…
http://poj.org/problem?id=2484 1和2时Alice必胜,3时Bob必胜,其他情况下Bob只需要在Alice取过之后取一次将剩下的硬币链平均分为两份,然后Alice怎么取Bob对称着取就可以了. 真是巧妙. 代码 #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostream> #include<ma…
相比数据结构的题..感觉这种想啊想的题可爱多了~~~代码量还少.... 题目链接: http://poj.org/problem?id=2484 题意: 一圈n个硬币,两人轮流从中取一或两个硬币,(只能取相邻的两枚硬币),取完的获胜,问谁赢? 分析: 这里注意,连续的硬币中取出若干个后,被分割开的就不算连续的硬币了. 首先还是找是否存在对称状态,只要是存在对称状态,后手模仿先手,最后后手必赢. 假设先手第一次拿走了1或者2个硬币,圈被分裂成一条链,后手在链的中间部位拿走1或者2个硬币,将链分为两…
A Funny Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3861   Accepted: 2311 Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 106) coins in a circle, as Figure 1 shows. A mo…
A Funny Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4639   Accepted: 2855 Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 106) coins in a circle, as Figure 1 shows. A mo…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6397   Accepted: 3978 Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 106) coins in a circle, as Figure 1 shows. A move consists i…
题目链接: 传送门 A Funny Game Time Limit: 1000MS     Memory Limit: 10000K Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 106) coins in a circle, as Figure 1 shows. A move consists in removing one o…
Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 10 6) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins, leaving all other coins untouched. At least…
一开始看这道博弈题的时候我就用很常规的思路去分析了,首先先手取1或者2个coin后都会使剩下的coin变成线性排列的长条,然后无论双方如何操作都是把该线条分解为若干个子线条而已,即分解为若干个子游戏而已,我想起刘汝佳的大白书上有类似的例题(不过复杂好多),于是便用同样的方法去做了,以sg(x)表示当前连续x个coin的状态的sg函数值,则当从左侧起分别取一个或相邻的两个时,不难得出其后继状态:sg(y)^sg(x-1-y)(0<=y<=(x-1)/2),sg(y)^sg(x-2-y)(0<…
题目链接题意:有n个硬币排成一圈,两个人轮流操作,每次可以取走一个或者相邻的连个硬币(只算最开始相邻的,取之后才相邻的不算),问先手必胜还是必败. 这个题可以证明若n>=3,则先手必败.对称博弈若n>=3,先手第一次必然把这个环拆成一个链,然后无论这条链长度的奇偶,后手总是可以把这条链分成两条相等的链,于是先手在一条链上做什么,后手就可以做什么.知道先手无法操作,后手胜. #include<iostream> #include<cstdio> #include<a…