Euclid's Game(0099)

Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 1855 Accepted: 589
 
Description
Starts with two unequal positive numbers (M,N and M>N) on the board. Two players move in turn. On each move, a player has to write on the board a positive number equal to the difference of two numbers already on the board; this number must be new, i.e., different from all the numbers already on the board. The player who cannot move loses the game. Should you choose to move first or second in this game? 
 
According to the above rules, there are two players play tihs game. Assumptions A write a number on the board at first, then B write it. 
Your task is write a program to judge the winner is A or B.
 
(由两个不等正数开始,这两个数写在板子上,M>N,每人只能在板上写出板子上已有数的差值的绝度值,这个值必须是和之前不同的。谁不能写出谁即输掉这场游戏,所以你是该先手还是后手,才能赢得这场比赛?)
 
(根据这个规则,假定A首先写,然后B写)
 
(你的任务是写个程序判断谁是赢家)
 
Input
Two unequal positive numbers M and N , M>N (M<1000000)
 
Output
A or B
 
Sample Input
3 1
 
Sample Output
A
 
Hint
Source
algorithm text book
 
#include<stdio.h>
int gcd(int a,int b)
{
int c;
while(c)
{
c=a%b;
a=b;
b=c;
}
return a;
}
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if((a/gcd(a,b))%==)
printf("B\n");
else
printf("A\n");
return ;
}

注:每次写的数,只能是最开始两个数的最大公约数的k(k最大为M/gcd(M,N))倍,所以判断M/gcd(M,N)奇偶性即可。

SWUST OJ Euclid's Game(0099)的更多相关文章

  1. [Swust OJ 404]--最小代价树(动态规划)

    题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535   Des ...

  2. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  3. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  4. [Swust OJ 1023]--Escape(带点其他状态的BFS)

    解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535     Descript ...

  5. [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)

    题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  6. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  7. [Swust OJ 1026]--Egg pain's hzf

      题目链接:http://acm.swust.edu.cn/problem/1026/     Time limit(ms): 3000 Memory limit(kb): 65535   hzf ...

  8. [Swust OJ 1139]--Coin-row problem

    题目链接:  http://acm.swust.edu.cn/contest/0226/problem/1139/ There is a row of n coins whose values are ...

  9. [Swust OJ 385]--自动写诗

    题目链接:http://acm.swust.edu.cn/problem/0385/ Time limit(ms): 5000 Memory limit(kb): 65535    Descripti ...

随机推荐

  1. fiddler抓包可以抓到电脑数据抓不到手机上的数据------防火墙问题

    1.确保手机与电脑处于同一局域网,网络没问题,手机代理设置无误 2.确保fiddler设置没有任何问题 3.如果此时还是无法抓包,请打开控制面板----Windows防火墙------允许程序通过Wi ...

  2. Django_前介

    Django 1.软件框架 ​ 一个公司是由公司中的各部部门来组成的,每一个部门拥有特定的职能,部门与部门之间通过相互的配合来完成让公司运转起来. ​ 一个软件框架是由其中各个软件模块组成的,每一个模 ...

  3. Java常见异常说明汇总

    1. java.lang.nullpointerexception 这个异常大家肯定都经常遇到,异常的解释是"程序遇上了空指针",简单地说就是调用了未经初始化的对象或者是不存在的对 ...

  4. redhat7.0安装postgresql

    安装命令 sudo yum install postgresql-server 查看安装的包 sudo yum list postgres* postgresql.x86_64 postgresql- ...

  5. 17)PHP,函数基础和参数问题

    (1)函数定义形式: function 函数名字(形参1,形参2,形参3........) { 函数体(代码块) } (2)调用形式: 第一种:没有返回值的函数,则调用独立的语句 函数名(实参1,实参 ...

  6. debian8.8安装sougou输入法

    传送门:http://www.cnblogs.com/ligongzi/p/6137601.html 亲测可用

  7. rsync+nfs+sersync实战案例

    回顾: 1.rsync 统一备份各个服务器的配置文件或重要文件 系统配置文件 日志文件 系统日志文件 messages.secure.cron 服务日志文件 access_log.access.log ...

  8. 吴裕雄--天生自然python学习笔记:python 建立 Firebase 数据库连接

    Python 程序通过 python-firebase 包可以存取 Firebase 数据库. 使用 python-firebase 包 首先必须安装 python-firebase 包,安装方法如下 ...

  9. day11-random模块-随机

    import random # 一.随机小数: print(random.random()) # 0.848972270116501结果是0-1之间的随机小数 print(random.uniform ...

  10. rest framework-版本-长期维护

    ###############  版本   ############### # # 版本的问题: # rest_framework.versioning.URLPathVersioning # 一般就 ...