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. Ubuntu 安装软件时显示:无法获得锁 /var/lib/dpkg/lock -open(资源暂时不可用)

    出错状况:在用 sudo apt-get install 安装软件时,结果终端提示: 无法获得锁 /var/lib/dpkg/lock -open(资源暂时不可用) 无法锁定管理目录(var/lib/ ...

  2. layui select恢复默认值

  3. ZJNU 2204 - dzj的数学作业

    我猜这个数列可以直接从大到小凑…… 推出帕多瓦数列每一项,从大到小循环 遇到小于等于x的项就减掉这一项 全部循环完毕后判断x是否为0即可 #include<stdio.h> typedef ...

  4. 处理Ajax请求跨域问题

    ajax跨域的原理 ajax出现请求跨域错误问题,主要原因就是因为浏览器的“同源策略”. CORS是一个W3C标准,全称是"跨域资源共享"(Cross-origin resourc ...

  5. tensorflow训练Oxford-IIIT Pets

    参考链接https://github.com/tensorflow/models/blob/master/object_detection/g3doc/running_pets.md 先参考https ...

  6. Python 爬虫 爬取图片入门

    爬虫 网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动的抓取万维网信息的程序或者脚本. 用户看到的网页实质是由 HTML 代码构成的,爬 ...

  7. vim下看C++代码

    看C++代码, 缺少合适的编辑器,捣鼓vim. 安装Vundle, 用于插件管理 git clone https://github.com/VundleVim/Vundle.vim.git ~/.vi ...

  8. tesseract系列(1) -- tesseract用vs编译成库

    1.下载teseract 下载地址github:     https://github.com/tesseract-ocr/tesseract/releases/ 2.编译源码 源码的编译有两种方式 ...

  9. 【Java杂货铺】JVM#虚拟机加载机制

    代码编译的结果从本地机器码变为字节码,是储存格式发展的一小步,却是编程语言发展的一大步--<深入理解Java虚拟机> 虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验.转化 ...

  10. Laravel 操作指令

    php artisan migrate —path=database/migrations/v1 更新表数据 php artisan make:migration create_channels_ta ...