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. UML-类图-构造型应用场景是什么?

    1.什么是构造型? 抽象出来的标准的模型元素. 2.有哪些? 1.预定义的,如:<<destory>> 2.自定义的 3.自定义

  2. tensorflow实现sphereFace网络(20层CNN)

    #coding:utf-8 import tensorflow as tf from tensorflow.python.framework import ops import numpy as np ...

  3. python妹子图爬虫5千张高清大图突破防盗链福利5千张福利高清大图

    meizitu-spider python通用爬虫-绕过防盗链爬取妹子图 这是一只小巧方便,强大的爬虫,由python编写 所需的库有 requests BeautifulSoup os lxml 伪 ...

  4. 决策树分类回归,ID3,c4.5,CART,及其Python代码

    决策树模型 内部节点表示一个特征或者属性,叶子结点表示一个类.决策树工作时,从根节点开始,对实例的每个特征进行测试,根据测试结果,将实例分配到其子节点中,这时的每一个子节点对应着特征的一个取值,如此递 ...

  5. gcc -c xx.c 选项讲解

    -c选项表示编译.汇编指定的源文件(也就是编译源文件),但是不进行链接.使用-c选项可以将每一个源文件编译成对应的目标文件. 目标文件是一种中间文件或者临时文件,如果不设置该选项,gcc 一般不会保留 ...

  6. Hard Disk Drive(MBR)

    这里讲的主要是网上所谓的老式磁盘,它是由一个个盘片组成的,我们先从个盘片结构讲起.如图1所示,图中的一圈圈灰色同心圆为一条条磁道,从圆心向外画直线,可以将磁道划分为若干个弧段,每个磁道上一个弧段被称之 ...

  7. Spring Boot Session 超时时间

    springboot session https://www.jianshu.com/p/523572937db8 springboot2以上版本设置session超时时间 https://blog. ...

  8. ios 接入微信开发 新版

    首先在服务器所在域名(https://www.test.com)根目录创建apple-app-site-association文件 { "applinks": { "ap ...

  9. Clairaut 定理 证明

    (Clairaut 定理)设 $E$ 是 $\mathbf{R}^n$ 的开子集合,并设 $f:\mathbf{E}\to \mathbf{R}^{m}$ 是 $E$ 上的二次连续可微函数.那么对于一 ...

  10. Angular开发者指南(三)数据绑定

    数据绑定 AngularJS应用程序中的数据绑定是模型和视图组件之间的数据的自动同步. AngularJS实现数据绑定的方式可以将模型视为应用程序中的单一来源. 视图是模型在任何时候的投影. 当模型更 ...