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. goto语句 switch语句

    goto语句 #include <iostream> using namespace std; int main() { int i = 1; number: i++; std::cout ...

  2. DB2中的转义字符

    1.数据库脚本 )); ,'20%'); ,'OLIVER_QIN'); ,'AA''') 2.以下是DB2的转义字符 2.1 对“%”的转义 SELECT * FROM OLIVER_11 WHER ...

  3. oh-my-zsh配置你的zsh提高shell逼格终极选择

    抱歉,这篇博文推迟发布了,人都是有惰性的...看在这个牛逼闪闪的标题就原谅我吧! 为何这篇文章要归类到 mac 下? 第一个问题,稍后我们说明下. zsh是个什么东东? 第二个问题... 你应该稍微接 ...

  4. spring aop 使用注解方式总结

    spring aop的注解方式:和xml的配置方式略有区别,详细如下: 1.首先还是建立需要的切面类:切面类里面定义好切点配置,以及所有的需要实现的通知方法. /** * */ package com ...

  5. html5 shiv

    使用html5标签吧!ie6.ie7.ie8不支持怎么办?它的原理是如此的简单:    1.document.createElement("ele");  // js虚拟创建一个元 ...

  6. linux调整分区大小

    查看一下当前分区情况 1 2 3 4 5 6 7 8 [root@localhost ~]# df -h Filesystem            Size  Used Avail Use% Mou ...

  7. 关于开始学习Leetcode的第一帖

    从明天开始,白天在实验室完成工作,晚上来图书馆换个环境去学习算法数据结构等计算机基础性的技能.在LeetCode这个平台上做题. 现在感觉自己在算法和数据机构这方面实在是太薄弱了,需要慢慢的捡起来来, ...

  8. Eclipse Indigo 3.7.0 安装GIT插件提示 requires 'bundle org.eclipse.team.core(转)

    文章参考来源:http://showlike.iteye.com/blog/1958538 错误提示: Cannot complete the install because one or more ...

  9. (转)android Fragments详解一:概述

    Fragment是activity的界面中的一部分或一种行为.你可以把多个Fragment们组合到一个activity中来创建一个多面界面并且你可以在多个activity中重用一个Fragment.你 ...

  10. 自己编写基于MVC的轻量级PHP框架

    做WEB开发已有三年,每次都写重复的东西, 因此,想自己写一下框架,以后开发方便.本人之前asp.NET一年开发,jsp半年,可是后来因为工作的原故换成PHP.其实很不喜欢PHP的语法.还有PHP的函 ...