XTU OJ 1209 Alice and Bob 2014(嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛)
Problem Description
The famous "Alice and Bob" are playing a game again. So now comes the new problem which need a person smart as you to decide the winner. The problem is as follows: They are playing on a rectangle paper, Alice and Bob take turn alternatively, for each turn,
a people cut the rectangle vertically or horizontally, the result two rectangle after cut must be IDENTICAL, also the side must be integer, after the cut, one rectangle will be descarded. The first people fail to cut lose the game. Of course, Alice makes first
as usual.
Input
First Line contains an integer t indicate there are t cases(1≤t≤1000) For each case: The input consists of two integers w and h(1≤w,h≤1,000,000,000), the size of rectangle.
Output
First output Case number For each case output Alice or Bob, indicate the winner.
Sample Input
2
1 2
2 2
Sample Output
Case 1: Alice
Case 2: Bob
比赛时对于题目难易的分析还是不够;
#include <iostream>
#include <cstdio>
using namespace std;
int j;
void compete(int w,int h)//递归
{
if(w%2==0) //这里还能够写成 (! w&1)
{
w/=2;
j++;
compete(w,h);
}
else if(h%2==0)
{
h/=2;
j++;
compete(w,h);
}
}
int main()
{
int t,i;
int w,h;
scanf("%d",&t);
for(i=1;i<=t;i++)
{
j=0;
scanf("%d%d",&w,&h);
compete(w,h);
printf("Case %d: ",i);
if(j%2==0)
printf("Bob\n");
else
printf("Alice\n");
}
return 0;
}
XTU OJ 1209 Alice and Bob 2014(嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛)的更多相关文章
- 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...
- 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Highway
Highway Accepted : 122 Submit : 393 Time Limit : 4000 MS Memory Limit : 65536 KB Highway In ICPC ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- 2014 Super Training #6 A Alice and Bob --SG函数
原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- bzoj4730: Alice和Bob又在玩游戏
Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...
- sdutoj 2608 Alice and Bob
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...
- hdu 4268 Alice and Bob
Alice and Bob Time Limit : 10000/5000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tota ...
- ACdream 1112 Alice and Bob(素筛+博弈SG函数)
Alice and Bob Time Limit:3000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit ...
随机推荐
- Windows下命令行直接编译程序
D:\> cl hello.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Cop ...
- Less 教程
1. 关于 less sass 的预编译处理器 LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承, 运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, ...
- c#基础: 线程的初级用法总结
启动一个线程的两种方法: a.使用无参的方法 Thread thread1 = new Thread(new ThreadStart("调用的方法名")): ...
- Oracle - SQL 错误: ORA-00917: 缺失逗号
ORACLE SQL语句中int型插入数据库时,不要加引号.
- Java的优先级
序列号 符号 名称 结合性(与操作数) 目数 说明 1 . 点 从左到右 双目 ( ) 圆括号 从左到右 [ ] 方括号 从左到右 2 + 正号 从右到左 单目 - 负号 从右到左 单目 ++ 自增 ...
- Xcode快捷键 ---- 提高效率
Mac中主要有四个修饰键,分别是Command,Control,Option和Shift. 1. ⌘ + L 搜索行数,输入行数,调到指定行数 2.⌘ + shift + O 查询flie ...
- QT5-控件-QDateEdit 和 日期类QDate
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDate> #inclu ...
- T-SQL语句——UNION, EXCEPT, INTERSECT
UNION,EXCEPT, INTERSECT关键字用于对集合的查询,它们的作用分别为: UNION:合并两个或多个 SELECT 语句的结果集,并把重复结果去除: UNIONALL:合并两个或多个 ...
- android之ListView,详细介绍实现步骤,举例,自定义listview适配器
android之ListView,详细介绍实现步骤,举例,自定义listview适配器 本文来源于www.ifyao.com禁止转载!www.ifyao.com android中如何使用listVie ...
- cubieboardtruck安装
1.命令关闭所有led灯 ls /sys/class/leds/*/brightness | xargs -i -n1 echo "echo 0 > {}" | sh 如果需 ...