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 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<3时有Alice必胜,n=3时Bob胜,当n>3时,无论Alice如何操作,Bob总可以通过操作使得剩下两条完全相同的链,之后通过对称Alice的操作最终获胜。

【代码】

 #include<cstdio>

 int main() {
int n;
while(scanf("%d",&n)== && n) {
if(n>=) puts("Bob");
else puts("Alice");
}
return ;
}

poj 2484 A Funny Game(博弈)的更多相关文章

  1. POJ 2484 A Funny Game [博弈]

    题意:n枚硬币围成一个圈,每次每个人可以从中取走一枚或者相邻的两枚(如果两枚硬币原本中间隔着一枚硬币,后来被取走,这两枚硬币不算相邻).谁取走最后一枚硬币谁就赢了. 思路:我们可以找找规律. 首先,n ...

  2. POJ 2484(对称博弈)

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

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

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

  4. POJ 2484 A Funny Game【博弈】

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

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

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

  6. POJ Football Game 【NIMK博弈 && Bash 博弈】

    Football Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 451   Accepted: 178 Descr ...

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

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

  8. POJ 2484

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

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

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

随机推荐

  1. .NET3.5中的高性能 Socket API

    转载:http://www.cnblogs.com/TianFang/archive/2007/11/09/954730.html 在 .NET Framework 2.0 版本中,System.Ne ...

  2. PL/SQL 中文转换为\uxxxx格式(unicode)

    用plsql生成json的时候,经常要处理中文的情况. SELECT replace(asciistr('你好,,hello'),'\','\u') FROM dual 输出:\u4F60\u597D ...

  3. Maven3(笔记一)

    第一节:Maven 简介 百度百科:Maven 官网:http://maven.apache.org/ 第二节:Maven 安装与配置 Maven 下载:http://maven.apache.org ...

  4. java中事件处理探究

    事件的触发可以源于用户,也可以用代码来主动设置事件的发生.如setSelected()java.awt.event中 听众接口 事件类 适配器类 ComponentListener     Conta ...

  5. VS番茄助手安装(vs2015+vs2010):卸载之前的vs助手再安装新版本

    1 卸载之前的vs助手 vs2010: vs2015: 2 安装新版本

  6. ZOJ 2015 10月份 月赛 3911 Prime Query

    这道题我改啊,改啊,交啊,就对了. #include <stdio.h> #include <stdlib.h> #include <math.h> #includ ...

  7. C#如何释放已经加载的图片 (转)

    使用Image.FromFile取磁盘上的图片时,这个方法会锁定图片文件,而且会导致内存占用增大, 有几种方法解决: 一:将Image类转换成Bitmap类 System.Drawing.Image ...

  8. Firebug中命令行栏(Commandlinie)的使用介绍和总结

    Commandlinie是Firebug中总有用的一个特性.如果你有Microsoft Visual Studio的使用经验,你就会知道“Immediate Window” 和“Watch Windo ...

  9. javascript闭包传参和事件的循环绑定

    今天看到一个javascript的题目,按常理循环绑定事件,但是得到的结果却不是想要的. <a href="#">text</a><br>< ...

  10. DataTable 无法转换的错误

    目前基本上检索都已经离不开Linq了.所以最近在Linq的过程中出现了一些意外情况,特此记录下来. 先描述一下场景: 有一个查询的要求是这样的,检索出Status > 1 的数据.因为要根据其他 ...