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 <= 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>2?printf("Bobn"):printf("Alicen");
return 0;
}
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 【性能】688- 前端性能优化——从 10 多秒到 1.05 秒
- 第十六篇 zabbix创建Trigger
- 如何通过程序(java代码)提高你的博客访问量
- zabbix_get [12429]: Check access restrictions in Zabbix agent configuration
- 【设计模式】689- TypeScript 设计模式之观察者模式
- Found a swap file by the name ".jsidInspector.py.swp"
- CentOs7下部署tomcat文件服务器
- 【拓展】未来的JavaScript记录与元组
- 【Vuejs】690- Vue新特性:CSS 中使用 JS 变量
- Zabbix监控之从Kafka中获取消费进度和lag
- 将UTC(字符串包含TZ的时间)时间转换成本地时间 python
- centos7安装telnet服务
- linux vim编辑器之环境设置
- JAVA实现UTC时间转换成北京时间
- JDK8 LocalDateTime转换成时间戳