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. PHP24 自定义分页类

    分页类的定义 <?php /** * Class MyPage 分页类 * @package core */ class MyPage { private $totalCount; //数据表中 ...

  2. 雷林鹏分享:Lua 数据类型

    Lua是动态类型语言,变量不要类型定义,只需要为变量赋值. 值可以存储在变量中,作为参数传递或结果返回. Lua中有8个基本类型分别为:nil.boolean.number.string.userda ...

  3. Spring boot 项目打成war包并在idea中运行

    1. 修改pom文件原来是jar改成<packaging>war</packaging> 2. 在pom文件中添加移除内置tomcat并且添加添加servlet-api的依赖. ...

  4. 洛谷——P3939 数颜色(暴力vecotr+二分)

    P3939 数颜色 $vecotr$里二分就是好用,全是$STL$ 颜色数目比较少,可以对每一种颜色弄一个$vector$记录一下,查找$l,r$内颜色数为$x$的兔子数,直接在$G[x]$这个$ve ...

  5. opencv加载图片和视频

    一.加载图片: 1.先放一段最简单的加载图片的代码 import cv2 as cv #引用opencv库image = "D:/Image/test.jpg" #确定图片所在路径 ...

  6. 洛谷 P1085 不高兴的津津

    这道题就是经典的条件分支的题https://www.luogu.org/problemnew/show/P1085 code: #include <stdio.h> int main() ...

  7. JS应用之正则表达式

    定义 正则表达式是用于匹配字符串中字符组合的模式. 创建正则表达式 两种方式: 1.new RegExp() let pattern1 = new RegExp('cat'); //第一个参数字符串 ...

  8. 数据结构( Pyhon 语言描述 ) — — 第4章:数据和链表结构

    数据结构是表示一个集合中包含的数据的一个对象 数组数据结构 数组是一个数据结构 支持按照位置对某一项的随机访问,且这种访问的时间是常数 在创建数组时,给定了用于存储数据的位置的一个数目,并且数组的长度 ...

  9. (一)java集合框架——Iterable

    Iterable接口是java 集合框架的顶级接口,实现此接口使集合对象可以通过迭代器遍历自身元素,我们可以看下它的成员方法 修饰符和返回值 方法名 描述 Iterator<T> iter ...

  10. HDU-1041-Computer Transformation,大数递推,水过~~

                                                                                  Computer Transformatio ...