A Funny Game

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6178   Accepted: 3861

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时,先手必胜。n>2时,后手以中心对称模仿先手,必胜。
 //2017-10-26
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int main()
{
int n;
while(cin>>n && n){
if(n <= )cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;
} return ;
}
 import java.util.*;

 public class Main{
public static void main(String args[]){
int n;
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
n = cin.nextInt();
if(n == 0)break;
if(n <= 2)System.out.println("Alice");
else System.out.println("Bob");
}
}
}

POJ2484的更多相关文章

  1. POJ2484 A Funny Game[博弈论]

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

  2. [poj2484]A Funny Game(对称博弈)

    题目:http://poj.org/problem?id=2484 题意:n个石子围成一个圈,两个人轮流取,每次可以取一个石子或者相邻的两个石子,问先手胜还是后手胜 分析: 典型的对称博弈 如果n&g ...

  3. [POJ2484]A Funny Game

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4533   Accepted: 2780 Description Alice ...

  4. 【博弈论】poj2484 A Funny Game

    如果当前状态可以根据某条轴线把硬币分成两个相同的组,则当前状态是必败态. 因为不论在其中一组我们采取任何策略,对方都可以采取相同的策略,如此循环,对方必然抽走最后一枚硬币. 因为我们先手,因此抽完后盘 ...

  5. 【POJ】1067 取石子游戏(博弈论)

    Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...

  6. 博弈论BOSS

    基础博弈的小结:http://blog.csdn.net/acm_cxlove/article/details/7854530 经典翻硬币游戏小结:http://blog.csdn.net/acm_c ...

  7. 【Mark】博弈类题目小结(HDU,POJ,ZOJ)

    转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 首先当然要献上一些非常好的学习资料: 基础博弈的小 ...

随机推荐

  1. 9.视差特效、回弹动画、overScrollBy

    视差特效 * 应用场景: 微信朋友圈, QQ空间, 微博个人展示,向下拉出,松开回弹* 功能实现: > 1. 重写overScrollBy > 2. 松手之后执行动画, 类型估值器 .  ...

  2. Java之JDK7的新语法探索

    Java之JDK7的新语法探索 前言 感谢! 承蒙关照~ 字面量: 各种精致的表达方式: 八进制以0开头,十六进制0X开头,二进制以0B开头. 二进制运算时,应该写成这样才直观: &15 -& ...

  3. Kali学习笔记22:缓冲区溢出漏洞利用实验

    实验机器: Kali虚拟机一台(192.168.163.133) Windows XP虚拟机一台(192.168.163.130) 如何用Kali虚拟机一步一步“黑掉”这个windowsXP虚拟机呢? ...

  4. ubuntu 16.04 和win10双系统ubuntu无法更新问题解决

    错误:E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. ...

  5. [原创]K8Cscan插件之C段旁站扫描\子域名扫描

    [原创]K8 Cscan 大型内网渗透自定义扫描器 https://www.cnblogs.com/k8gege/p/10519321.html Cscan简介:何为自定义扫描器?其实也是插件化,但C ...

  6. Spring Cloud微服务中网关服务是如何实现的?(Zuul篇)

    导读 我们知道在基于Spring Cloud的微服务体系中,各个微服务除了在内部提供服务外,有些服务接口还需要直接提供给客户端,如Andirod.IOS.H5等等. 而一个很尴尬的境地是,如果直接将提 ...

  7. ubuntu16.04 Docker默认存储路径修改

    Ubuntu 16.04 Docker默认存储路径修改

  8. asp.net core异步进行新增操作并且需要判断某些字段是否重复的三种解决方案

    之前碰到asp.net core异步进行新增操作并且需要判断某些字段是否重复的问题,进行插入操作的话会导致数据库中插入重复的字段!下面把我的解决方法记录一下,如果对您有所帮助,欢迎拍砖! 场景:EFC ...

  9. css笔记详解(1)

    css讲解 版权声明 本文原创作者:雨点的名字 作者博客地址:https://home.cnblogs.com/u/qdhxhz/ 首先在我们学习css之前先来思考一个问题,为什么html标签上不直接 ...

  10. 【python】re库 正则的一些过滤和把str拆分成list案例 以及json dict类型

    0x01: 部分参考:https://www.cnblogs.com/edwardsun/p/4421773.html match(string[, pos[, endpos]]) | re.matc ...