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. Linux环境系列 之【配置虚拟机】

    前言懒得讲, 不给人解决问题的程序员不是好的程序员,所有老规矩,直接上干货 This is 系列故事 如果你从这里单独看那是没有任何问题的,但是你是小白的话建议你跳去 ☞从头开始[环境概述] ☞本章节 ...

  2. Java web之javascript(2020.1.6)

    1.js输出: windows.alert()---警告框 document.write()---写到html文档中 innerHTML---写到HTML元素 console.log()---写到浏览 ...

  3. centos 7.2 php7+ 安装elasticsearch

    安装 Elasticsearch-php 的安装需要满足以下 4 个需求: PHP 7.0.0 或更高版本 Composer ext-curl:PHP 的 Libcurl 扩展(详情查看下方注意事项) ...

  4. python uiautomator2 新版本2.4.6之watcher的玩法

    最近将uiautomator2升级到最新版本了,运行之前的脚本发现涉及watcher部分的全部报错,大家来看看新版本的watcher如何玩 用法举例 注册监控 # 常用写法,注册匿名监控 d.watc ...

  5. 主流CAD菜单开发

    AutoCAD Inventor Solidedge Proe UGNX

  6. Microsoft.Office.Inter.Excel.dll在調用時可能會出現如下錯誤

    Microsoft.Office.Inter.Excel.dll在調用時可能會出現如下錯誤,具體解決方案如下: 1. 錯誤資訊:檢索 COM 類工廠中 CLSID 為{00024500-0000-00 ...

  7. echart图表demo

    <!DOCTYPE html><html><head> <title>echarts</title></head><scr ...

  8. CI_CD(jenkins)公司实战_未完成版

    环境准备 #三台服务器,不同的ip centos   镜像时:CentOS Linux release 7.6.1810 (Core) gitlab-ce 版本是:11.11.3 jenkins   ...

  9. 在select2插件中append下拉选,点击没反应的解决

    今天前端大佬帮我解决了一个棘手的问题:克隆了已有系统的网页,尝试把复制下来的html改造成jsp.基本功能正常,然而点击新增按钮,出来的行无法点击下拉选,控制台也没报错. 项目用的是jeesite2. ...

  10. elastic search记录

    安装与启动 插件安装 中文分词器 https://github.com/medcl/elasticsearch-analysis-ik elastic api GET _search { " ...