POJ2484(水博弈)
2013-07-23 22:25
405 查看
题目:题目链接
题目的意思就是两个人轮流拿硬币,Alice先拿,Alice拿的时候可以选择拿走一个或者拿走相邻的两个,谁拿完最后的石子胜利。
分析:
努力努力...
题目的意思就是两个人轮流拿硬币,Alice先拿,Alice拿的时候可以选择拿走一个或者拿走相邻的两个,谁拿完最后的石子胜利。
分析:
当n==1 || n==2时,明显先手必胜。 当n==3时,明显先手必败。 由于每次只可取1或2个,而取2个时,2个必须相邻,推断有: 当n>3时, 若n为偶数,先手无论如何取,后手可在先手对称的位置上取同等数量,于是先手必败。 若n为奇数,先手取1个时,后手可在先手对称的位置上取2个,之后无论先手如何取,后手都可在先手对称的 位置上取同等数量,先手必败。 先手一开始取2个时,可如上推出先手必败。
代码:
#include <iostream> #include <cstdio> #include <string> #include <string.h> #include <map> #include <vector> #include <cstdlib> #include <cmath> #include <algorithm> #include <cmath> #include <queue> #include <set> #include <stack> using namespace std; int main() { int n; while(scanf("%d", &n)) { if(n==0) break; if(n <= 2) printf("Alice\n"); else printf("Bob\n"); } return 0; }
努力努力...
相关文章推荐
- POJ 2484 (博弈)
- POJ 2484 A Funny Game 简单博弈
- POJ 2484 —— 博弈
- poj 2484 A Funny Game(博弈)
- POJ 2484 简单博弈
- poj 2484 (对称式博弈)
- POJ 2484-A Funny Game硬币排成环(博弈-找规律)
- POJ 2484 A Funny Game (博弈)
- (poj 2484)A Funny Game(博弈,对称)
- 博弈 找规律 poj 2484
- 博弈,找规律_______A Funny Game(poj 2484)
- poj 2484 博弈--对称思想 15行代码以内解决
- POJ 2484 A Funny Game [博弈]
- poj 2484 博弈
- POJ 2484(博弈-对称博弈)
- 【POJ】2484 - A Funny Game 博弈
- poj 2484 A Funny Game (博弈)
- POJ 2484 A Funny Game【博弈】
- poj 2484 博弈(模仿对手)
- poj2484 博弈对称