博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2484 A Funny Game
阅读量:5895 次
发布时间:2019-06-19

本文共 1516 字,大约阅读时间需要 5 分钟。

A Funny Game

Time Limit: 1000MS   Memory Limit: 65536K
     

Description

Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 10
6) 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 <= 10
6). 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

1230

Sample Output

AliceAliceBob 结论:n=1或2,先手必胜,否则,先手必败 当n=1或2,先手一次取走 当n=3,先手取一次,后手再取一次 当n>3时,先手从任何地方取1或2,都会将环变成一个链,后手一定可以把这个链变成 两个长度相等的链 然后后手一定赢
#include
using namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF) { if(!n) return 0; if(n==1||n==2) printf("Alice\n"); else printf("Bob\n"); }}

 

 

转载于:https://www.cnblogs.com/TheRoadToTheGold/p/6746816.html

你可能感兴趣的文章
使用UITableView实现图片视差效果
查看>>
CentOS RHEL 安装 Tomcat 7
查看>>
erlang如何有效地监视大量的并发连接
查看>>
Apple Developer Registration and DUNS Number Not Accepted
查看>>
Hadoop学习笔记系列文章导航
查看>>
转一贴,今天实在写累了,也看累了--【Python异步非阻塞IO多路复用Select/Poll/Epoll使用】...
查看>>
iOS开发-NSOperation与GCD区别
查看>>
扩展方法使用
查看>>
Win7 64位 php-5.5.13+Apache 2.4.9+mysql-5.6.19 配置
查看>>
spring mvc 和ajax异步交互完整实例
查看>>
不同页面之间实现参数传递的几种方式讨论
查看>>
程序员进阶之路—如何独当一面
查看>>
SpringMVC中ModelAndView addObject()设置的值jsp取不到的问题
查看>>
Prometheus : 入门
查看>>
使用 PowerShell 创建和修改 ExpressRoute 线路
查看>>
PHP如何学习?
查看>>
谈教育与成长
查看>>
jni c++
查看>>
快速集成iOS基于RTMP的视频推流
查看>>
在C#中获取如PHP函数time()一样的时间戳
查看>>