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

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
 
 
比自己想象中的easy 1e9倍啊233
感觉这东西没法求SG,那么一定是个玄学题
事实证明自己还是太菜了
 
结论:当n==2或n==1是先手胜,否则后手胜
 
证明:
当$n$为偶数时,不论先手怎么走,后手总会根据中心对称模仿先手走
当$n$为奇数时,不论先手怎么走,后手总会进行与之相反的操作来构造成第一种情况
 
#include<cstdio>
int main()
{
int T_T;
while( scanf("%d",&T_T) && T_T )
T_T>?printf("Bob\n"):printf("Alice\n");
return ;
}

POJ 2484 A Funny Game(智商博弈)的更多相关文章

  1. poj 2484 A Funny Game(博弈)

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

  2. POJ 2484 A Funny Game【博弈】

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

  3. poj 1704 Georgia and Bob(阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9363   Accepted: 3055 D ...

  4. POJ 2484(对称博弈)

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

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

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

  6. POJ 2484 A Funny Game [博弈]

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

  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. HTML5与CSS3权威指南笔记案例1

    第1章 <!DOCTYPE html> <meta charset = "UTF-8"> <title> Search </title&g ...

  2. Spring Boot 主类及目录结构介绍

    Spring Boot 与传统项目最大的区别是,传统项目都是打成 WAR 包部署到服务器上面,需要额外的 Servlet 容器, 而 Spring Boot 则可以直接打成 jar 包,并内置集成了 ...

  3. python应用-爬取猫眼电影top100

    import requests import re import json import time from requests.exceptions import RequestException d ...

  4. 2,linux入门到上手-ssh安装配置及虚拟机基本使用

    ssh配置 1,打开"终端窗口",输入 "sudo apt-get update" --> 回车 --> "输入当前登录用户的管理员密码& ...

  5. hd1007

    #include <iostream> #include <algorithm> #include <cmath> using namespace std; str ...

  6. EntityFramework中对象的状态管理(笔记)

    刚开始接触EF框架的时候总是不明白: 为什么查询出来的对象 Remove().再 SaveChanges()就会把数据删除.而自己 new 一个Person()对象,然后 Remove()不行? 为什 ...

  7. C#系列之聊聊.Net Core的InMemoryCache

    作者:暴王 个人博客:http://www.boydwang.com/2017/12/net-core-in-memory-cache/ 这两天在看.net core的in memory cache, ...

  8. ES搜索结果调优

    访问我的博客 自从使用 ElasticSearch 重构了主站的搜索项目之后,之后又陆续接入了其他两个项目,目前使用 SpringBoot 方式跑了一个伪集群,主站使用的时候,比较稳定,没有人反馈说有 ...

  9. leetcode — spiral-matrix-ii

    import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Source : https://o ...

  10. oracle12c创建用户提示ORA-65096:公用用户名或角色无效

    1.背景 以前一直用的是oracle11g,创建用户一直没有问题, 今天在oracle12c上创建用户,报错了.如下图: 我很郁闷, 就打开了oracle官方网站找了下, 发现创建用户是有限制的. 2 ...