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. 前端 (cookie )页面进入存储一次

     <!--引入jq--> <script> var isShowTip = window.sessionStorage.getItem("isShow") ...

  2. 文件默认权限umask掩码

    umask命令 作用:用于显示.设置文件的缺省权限 格式:umask   [-S] -S表示以rwx形式显示新建文件缺省权限 系统的默认掩码是0022 文件创建时的默认权限 = 0666 - umas ...

  3. memcached 经典问题或现象

    缓存雪崩现象及真实案例 缓存雪崩一般是由某个缓存节点失效,导致其他节点的缓存命中率下降, 缓存中缺失的数据 去数据库查询.短时间内,造成数据库服务器崩溃. 重启 DB,短期又被压跨,但缓存数据也多一些 ...

  4. Function()构造函数与函数直接量

    Function()构造函数与函数直接量 制作人:全心全意 在JavaScript中,除了可使用基本的function语句定义函数之外,还可以使用另外两种方式来定义,即使用Function()构造函数 ...

  5. 转:使用 /proc 文件系统来访问 Linux 内核的内容

    使用 /proc 文件系统来访问 Linux 内核的内容 https://www.ibm.com/developerworks/cn/linux/l-proc.html /proc 文件系统并不是 G ...

  6. KNN算法原理及实现

    1.KNN算法概述 kNN算法的核心思想是如果一个样本在特征空间中的k个最相邻的样本中的大多数属于某一个类别,则该样本也属于这个类别,并具有这个类别上样本的特性.该方法在确定分类决策上只依据最邻近的一 ...

  7. Java实现深拷贝和浅拷贝

    1.类实现Cloneable才可以进行对象拷贝 2.Cloneable只实现浅拷贝,需要实现深拷贝的必须要重写clone()方法 3.利用反序列化也可以实现深拷贝,但是反序列化耗时较长 n.浅拷贝是指 ...

  8. 年华利率n%

    年化利率12%指的是,在您出借的本金不减少的情况下,您一年后的利息将达到您出借本金的12%.也就是说,如果年化利率是12%,则每月您出借资金获得的利息是1%(12% / 12个月). 在有利网,您的投 ...

  9. xtu read problem training 2 B - In 7-bit

    In 7-bit Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 3 ...

  10. Linux基础之vi编辑器(二)

    vi 编辑器 man vim 一 打开文件,定义光标 vi +# test       打开文件,定位于#行.vi + test        打开test文件,定位于最后一行.vi +/patter ...