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


上次比赛的题,比赛完了就没去看它了。近期几天发现oj上有题目了,就把这几道题又一次做了一下。这道题,上次比赛的时候看到这道题还以为是博弈的题,以为要用DP去做,所以题目都没怎么去看,就直接跳过了,后来看到a的人比較多,就细致看了一下题目。读懂题意之后,发现事实上非常easy的一道题。做的慢了。

比赛时对于题目难易的分析还是不够;

记录一下自己的思路,首先分析给的w,h是奇数还是偶数,假设两个都是奇数,说明就不能再分了,分到1也不能分了(1也是奇数),当有一个是偶数都还能够继续分,我用的递归,假设能分就一直分下去,直到不能分为止;
以下是ac的代码;
#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湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛)的更多相关文章

  1. 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛

    比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...

  2. 2017年“嘉杰信息杯” 中国大学生程序设计竞赛全国邀请赛 Highway

    Highway Accepted : 122   Submit : 393 Time Limit : 4000 MS   Memory Limit : 65536 KB Highway In ICPC ...

  3. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  4. 2014 Super Training #6 A Alice and Bob --SG函数

    原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  6. bzoj4730: Alice和Bob又在玩游戏

    Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...

  7. sdutoj 2608 Alice and Bob

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time L ...

  8. hdu 4268 Alice and Bob

    Alice and Bob Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tota ...

  9. ACdream 1112 Alice and Bob(素筛+博弈SG函数)

    Alice and Bob Time Limit:3000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit ...

随机推荐

  1. Windows下命令行直接编译程序

    D:\> cl hello.cpp Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86 Cop ...

  2. Less 教程

    1. 关于 less sass 的预编译处理器 LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承, 运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, ...

  3. c#基础: 线程的初级用法总结

    启动一个线程的两种方法:     a.使用无参的方法       Thread thread1 = new Thread(new ThreadStart("调用的方法名")):   ...

  4. Oracle - SQL 错误: ORA-00917: 缺失逗号

    ORACLE SQL语句中int型插入数据库时,不要加引号.

  5. Java的优先级

    序列号 符号 名称 结合性(与操作数) 目数 说明 1 . 点 从左到右 双目 ( ) 圆括号 从左到右 [ ] 方括号 从左到右 2 + 正号 从右到左 单目 - 负号 从右到左 单目 ++ 自增 ...

  6. Xcode快捷键 ---- 提高效率

    Mac中主要有四个修饰键,分别是Command,Control,Option和Shift.     1. ⌘ + L 搜索行数,输入行数,调到指定行数   2.⌘ + shift + O 查询flie ...

  7. QT5-控件-QDateEdit 和 日期类QDate

    #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QDate> #inclu ...

  8. T-SQL语句——UNION, EXCEPT, INTERSECT

    UNION,EXCEPT, INTERSECT关键字用于对集合的查询,它们的作用分别为: UNION:合并两个或多个 SELECT 语句的结果集,并把重复结果去除: UNIONALL:合并两个或多个 ...

  9. android之ListView,详细介绍实现步骤,举例,自定义listview适配器

    android之ListView,详细介绍实现步骤,举例,自定义listview适配器 本文来源于www.ifyao.com禁止转载!www.ifyao.com android中如何使用listVie ...

  10. cubieboardtruck安装

    1.命令关闭所有led灯 ls /sys/class/leds/*/brightness | xargs -i -n1 echo "echo 0 > {}" | sh 如果需 ...