Alice and Bob

Accepted : 133   Submit : 268
Time Limit : 1000 MS   Memory Limit : 65536 KB 

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

题意:一块长方形纸张。Alice先对折剪下,再由Bob对折剪下。若一个人无论怎么剪面积都是小数的时候。这个人就输了这场比赛。

思路:长方形的面积是长乘以宽,无论以哪一个边对折剪下,那条边都是除以2,若有一条边长度变为小数,则这个人就输了。假设模拟。有可能会超时,运用边找规律。

当两条边都变成奇数的时候,则这个人就输了。也就是说。看偶数能对折几次。

Alice and Bob
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h> using namespace std; int main()
{
int n,m,i,j,k,a,b;
scanf("%d",&n);
for(m = 1;m <= n;m++)
{
scanf("%d%d",&a,&b);
i = 0;
while(a % 2 == 0)
{
i++;
a = a / 2;
}
while(b % 2 == 0)
{
i++;
b = b / 2;
}
if(i % 2 == 0)
printf("Case %d: Bob\n",m);
else
printf("Case %d: Alice\n",m);
}
return 0;
}

湘潭邀请赛——Alice and Bob的更多相关文章

  1. 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 ...

  2. 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)

    湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...

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

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

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

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

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

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

  6. 湘潭邀请赛 Hamiltonian Path

    湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...

  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. 2014 Super Training #6 A Alice and Bob --SG函数

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

随机推荐

  1. Linux之常用Shell脚本总结

    一.简介本文将总结一些常用的shell脚本,方便以后工作中使用. 二.shell脚本[a]定期备份mysql数据库,需结合cronb定时任务调度实现. #!/bin/bash#首先声明一些自定义变量 ...

  2. sleep 和wait的差别

    基本的差别 1.sleep 是Thread 类的方法,wait 是Object类中定义的方法 2.sleep()方法可以在任何地方使用 3.wait()方法只能在synchronized方法中使用,或 ...

  3. Maven实战读书笔记(三):Maven依赖

    3.1 依赖的配置 一个依赖声明可以包含下面元素: <dependencies> <dependency> <groupId></groupId> &l ...

  4. luogu P3353 在你窗外闪耀的星星

    问题:天空可以理解为一条数轴,在这条数轴上分布着许多颗星星,对于每颗星星都有它的位置Xi和自身的亮度Bi.而窗户所能看到的范围是一个给出的参数W,我们看到的星星也包括窗户边缘的星星.现在,要你求出调整 ...

  5. poj-1163 动态规划

    这道题目并不能直接使用递归,因为 7(1) 7(1)         7(1) 7(1)      7(2)         7(1) 7(1)       7(3)         7(3)    ...

  6. Java方法传递参数传值还是传址的问题

    这几天重构项目代码遇到一个疑问:可不可以在方法A中定义一个boolean变量b为false,然后A调用方法C把b传递到C方法中经过一些列业务判断后修改为true,C执行结束后A方法中b的值还是原来的f ...

  7. htmlpurifier的使用

    什么是htmlpurifier?? HTML Purifier是一个可以用来移除所有恶意代码(XSS),而且还能确保你的页面遵循W3C的标准规范的PHP类库. 在php里解决XSS最简单的方法是使用h ...

  8. (十八)python 3 回调函数

    回调函数:把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用来调用其所指向的函数时,我们就说这是回调函数.回调函数不是由该函数的实现方直接调用,而是在特定的事件或条件发生时由另外的一方调用的 ...

  9. python 学习总结3

    Python蟒蛇绘制 一.实现程序如下 import turtle turtle.setup (650, 350, 200, 200)#turtle的绘图窗体turtle.setup(width, h ...

  10. Druid配置

    spring-mybatis.xml <!-- 定义数据源Bean --> <!-- Druid --> <bean id="dataSource" ...