poj 2484 (对称式博弈)
来源:互联网 发布:无忧推广软件怎么样 编辑:程序博客网 时间:2024/06/06 07:09
A Funny Game
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5769 Accepted: 3591
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 or two adjacent coins, leaving all other coins untouched. At least one coin must be removed. Players alternate moves with Alice starting. The player that removes the last coin wins. (The last player to move wins. If you can't move, you lose.)
Figure 1
Note: For n > 3, we use c1, c2, ..., cn to denote the coins clockwise and if Alice remove c2, then c1 and c3 are NOT adjacent! (Because there is an empty place between c1 and c3.)
Suppose that both Alice and Bob do their best in the game.
You are to write a program to determine who will finally win the game.
Figure 1
Note: For n > 3, we use c1, c2, ..., cn to denote the coins clockwise and if Alice remove c2, then c1 and c3 are NOT adjacent! (Because there is an empty place between c1 and c3.)
Suppose that both Alice and Bob do their best in the game.
You are to write a program to determine who will finally win the game.
Input
There are several test cases. Each test case has only one line, which contains a positive integer n (1 <= n <= 106). There are no blank lines between cases. A line with a single 0 terminates the input.
Output
For each test case, if Alice win the game,output "Alice", otherwise output "Bob".
Sample Input
1230
Sample Output
AliceAliceBob
tips:
这道题目是直线上取石子的变形题目,对于直线上题目取石子的情况,先手是必胜态,
因为我们每一次都取对称位置的石子总能使自己获胜。对于这道题而言,先手取完之后,相当于再在直线上取,因此先收拾必败态,
但是要考虑到1,2这两个特殊值
#include<iostream>using namespace std;int n;int main(){while(cin>>n,n){if(n<=2)cout<<"Alice"<<endl;else cout<<"Bob"<<endl; } return 0;}
0 0
- poj 2484 (对称式博弈)
- POJ 2484(博弈-对称博弈)
- 对称博弈 POJ 2484
- POJ 2484-A Funny Game(对称博弈)
- poj 2484 博弈--对称思想 15行代码以内解决
- [ACM] poj 2484 A Funny Game(对称博弈)
- POJ-2484 A Funny Game (对称博弈)
- (poj 2484)A Funny Game(博弈,对称)
- POJ 2484 简单博弈
- poj 2484 博弈
- POJ 2484 (博弈)
- POJ 2484 简单博弈
- POJ 2484 —— 博弈
- 博弈 找规律 poj 2484
- poj博弈
- 对称博弈(coin game)
- 第六届省赛C--对称博弈
- poj2484A Funny Game+对称博弈
- Executors类执行多线程
- java中HashMap
- 【个人网络整理】NOIP / 省选 /NOI 知识点汇总
- 蓝桥杯-区间k大数查询(java)
- 英语学习点滴
- poj 2484 (对称式博弈)
- Linux中shell的模拟实现
- JSONCPP库引用(转)
- 事件对象
- 河南省第十届ACM程序设计大赛参赛心得
- 软件测试的分类
- redis并发问题
- 捕鱼类游戏计算方式的设计思路
- sublime text3 配置 ubuntu12.04