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 ...
随机推荐
- maven 打包源文件
1.The source plugin can be used to create a jar file of the project sources from the command line or ...
- [RxJS] Reactive Programming - Using cached network data with RxJS -- withLatestFrom()
So now we want to replace one user when we click the 'x' button. To do that, we want: 1. Get the cac ...
- DIV 与 Table 嵌套
当然可以了.对于DIV定义表示一块可显示 HTML 的区域. Specifies a container that renders HTML. 注释此元素在 Internet Explorer 3.0 ...
- c#、vb 自动属性
vb示例: Public Property Name() As String = "Bob" 等效于 Private _name As String = "Bob&quo ...
- Linux 统计代码行数命令
wc -l `find . -name '*.js'` wc -l `find . -regex ".*\.js"`
- Application 可以存储全局变量
Application.Lock(); Application["Name"]="小亮" Application.UnLock(); Response.Writ ...
- Git远程使用技巧
git作为强大的版本管理软件,已经得到了广泛的应用,很多人对于本地的git操作已经非常熟悉了.然而有的时候,我们也需要一个远程的,类似云的仓库来存储我们的一些代码.github给予了我们不限量的空间来 ...
- [转载]iOS开发:获取设备信息
开发iOS平台的应用的时候,可以获取iOS设备的设备信息,包括设备的名称,设备的机型,设备的iOS版本等等.设备信息主要来自 UIDevice 类. UIDevice *currentDevice = ...
- Android开发笔记之: 数据存储方式详解
无论是神马平台,神马开发环境,神马软件程序,数据都是核心.对于开发平台来讲,如果对数据的存储有良好的支持,那么对应用程序的开发将会有很大的促进作用.总体的来讲,数据存储方式有三种:一个是文件,一个是数 ...
- 关于HTML在手机端自适应的一个问题
在写页面的时候 一直以为是自己调节的大小,结果页面跳出来的效果完全不适应手机的尺寸和宽度 其实主要是因为head头中没有放自适应标签导致:下面就让我们来认识一下这款神器吧! 其实主要就是改掉HTML页 ...