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 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.

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

1
2
3
0

Sample Output

Alice
Alice
Bob

Source

POJ Contest,Author:Mathematica@ZSU
 
当N <= 2 时,必定是alice 赢 否则,bob只有吧剩下的个数取到偶数就必胜。
 
 #include <iostream>
#include <cstdio> using namespace std; int N;
int main()
{
while(~scanf("%d",&N) && N) {
printf("%s\n",N <= ? "Alice" : "Bob");
}
//cout << "Hello world!" << endl;
return ;
}

POJ 2484的更多相关文章

  1. POJ 2484(对称博弈)

    题目链接:http://poj.org/problem?id=2484 这道题目大意是这样的,有n个硬币围成一圈,两个人轮流开始取硬币(假设他们编号从1到n),可以选择取一枚或者取相邻的两枚(相邻是指 ...

  2. POJ 2484 A Funny Game 博弈论 对称博弈

    http://poj.org/problem?id=2484 1和2时Alice必胜,3时Bob必胜,其他情况下Bob只需要在Alice取过之后取一次将剩下的硬币链平均分为两份,然后Alice怎么取B ...

  3. POJ 2484 A Funny Game【博弈】

    相比数据结构的题..感觉这种想啊想的题可爱多了~~~代码量还少.... 题目链接: http://poj.org/problem?id=2484 题意: 一圈n个硬币,两人轮流从中取一或两个硬币,(只 ...

  4. poj 2484 A Funny Game(博弈)

    A Funny Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4639   Accepted: 2855 Desc ...

  5. POJ 2484 A Funny Game(智商博弈)

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6397   Accepted: 3978 Description Alice ...

  6. POJ 2484 A Funny Game(博弈论)

    题目链接: 传送门 A Funny Game Time Limit: 1000MS     Memory Limit: 10000K Description Alice and Bob decide ...

  7. 【POJ 2484】A Funny Game

    Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 &l ...

  8. POJ 2484 A Funny Game(神题!)

    一开始看这道博弈题的时候我就用很常规的思路去分析了,首先先手取1或者2个coin后都会使剩下的coin变成线性排列的长条,然后无论双方如何操作都是把该线条分解为若干个子线条而已,即分解为若干个子游戏而 ...

  9. [原博客] POJ 2484 A Funny Game

    题目链接题意:有n个硬币排成一圈,两个人轮流操作,每次可以取走一个或者相邻的连个硬币(只算最开始相邻的,取之后才相邻的不算),问先手必胜还是必败. 这个题可以证明若n>=3,则先手必败.对称博弈 ...

随机推荐

  1. Java中HashMap,LinkedHashMap,TreeMap的区别[转]

    原文:http://blog.csdn.net/xiyuan1999/article/details/6198394 java为数据结构中的映射定义了一个接口java.util.Map;它有四个实现类 ...

  2. SQL注入式攻击

    百度百科:http://baike.baidu.com/link?url=GQbJ2amTzTahZA7XJSBDLYYkN3waQ9JCoJ0l--tCWlvKQibe0YaH4hpmgEnLyn0 ...

  3. hdu 1277 全文检索

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1277 全文检索 Description 我们大家经常用google检索信息,但是检索信息的程序是很困难 ...

  4. android开发遇到SDK无法访问谷歌而安装不了的情况

    遇到SDK无法访问谷歌而安装不了的情况 1.修改C:\Windows\System32\drivers\etc的HOSTS文件,添加 #google_android更新203.208.46.146 d ...

  5. Linux如何开机自动运行自己的脚本

    博客分类: LINUX 脚本LinuxCentOSWindowsBash      记录这个事情是上次完成之后,今天要新加一个文件夹,一时之间忘记以前怎么做了,因为有几种方法,起码我知道三种方法,这里 ...

  6. jira插件带ui界面和几种方式

    http://localhost:2990/jira/plugins/servlet/issuecrud jira插件带ui界面和几种方式 https://developer.atlassian.co ...

  7. c++基础(一):数据类型和结构

    1.map map<int, int> rankDict;//定义map rankDict[1] = 5; rankDict[2] = 6;//map赋值 int dictSize = r ...

  8. “后PC”时代来临

    “后PC”时代来临 数年前,喜达屋酒店及度假村国际集团将总部搬迁至美国康涅狄格州斯坦福,这也让公司首席执行官Frits van Paasschen有机会“除尘换新”. 那么,Frits van Paa ...

  9. 使用 RestEasy 和 Apache Tomcat 构建 RESTful Web 服务

    第一次,用这个RestEasy框架,用的时候,总是提示,404的错误,郁闷,呵呵,不过经过努力,终于解决问题,特别留个标记. 关于404的错误,上网找了一大堆,也还不行. 我感觉应该是lib下面架包的 ...

  10. UIAlertControl swift

    let alertController = UIAlertController(title: "开始!", message: "游戏就要开始,你准备好了吗?", ...