HDU 2104 hide handkerchief
题解:由题目可以知道,如果n和m的最大公约数不为1,那么总有箱子是无法遍历的,所以求一遍GCD就可以判断了。
注意点:一定要记住判断是==,在做题时又忘了。
#include <cstdio>
int gcd(int a,int b)
{
if (b==) return(a);
else return(gcd(b,(a%b)));
} int main()
{
int n,m;
while(scanf("%d%d",&n,&m),n!=-||m!=-)
{
if (gcd(m,n)==)
puts("YES");
else puts("POOR Haha");
}
return ;
}
HDU 2104 hide handkerchief的更多相关文章
- 【HDOJ】2104 hide handkerchief
Problem Description The Children’s Day has passed for some days .Has you remembered something happen ...
- hdu 2104
#include <iostream> using namespace std; int gcd(int a,int b) { return (b?gcd(b,a%b):a); } int ...
- hide handkerchief
Problem Description The Children’s Day has passed for some days .Has you remembered something happen ...
- hdu 2104(判断互素)
hide handkerchief Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- 数学--数论--HDU 2104 丢手绢(离散数学 mod N+ 剩余类 生成元)+(最大公约数)
The Children's Day has passed for some days .Has you remembered something happened at your childhood ...
- HDU 1941 Hide and Seek(离散化+树状数组)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1941 题意:给出平面上n个点,找出一点p,使得距离p最近和最远的点的距离之差最小.输出这 ...
- hide handkerchief(hdu2104)
思考:这种找手绢就是,在判断是否互质.用辗转相除法(用来求最大公约数:a)进行判断.r=a%b;a=b;b=r;循环限制条件:除数b=0是结束除法.如果这时被除数a=1,则表示两个互质. #inclu ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- #C++初学记录(遍历)
hide handkerchief Problem Description The Children's Day has passed for some days .Has you remembere ...
随机推荐
- Xposed学习
刚接触,不是太懂,就昨天root荣耀6就花了一天时间,其实root早就ok,只是因为Xposed框架总是提示红色警告,以为不好用,后来试了几次发现,跟手机也有很大关系,有的不能很好的支持框架,有的模块 ...
- matlab GUI之常用对话框(一)-- uigetfile\ uiputfile \ uisetcolor \ uisetfont
常用对话框(一) 1.uigetfile 文件打开对话框 调用格式: [FileName,PathName,FilterIndex]=uigetfile or [FileName, ...
- Ubuntu 14.04 静态IP设置
1. 编辑/etc/network/interfaces vim /etc/network/interfaces 2.将以下五项添加到/etc/network/interfaces中 Static d ...
- office2010安装出错,windows installer服务不能更新一个或多个受保护的windows文件
转自:http://www.08lr.cn/article/1985.html office2010安装过程中出现如下图错误:windows installer 服务不能更新一个或多个受保护的wind ...
- IOS--当字符串返回的数据格式为xml/html时
今天一来办公室就接到客户返回的BUG,其中一个是因为后台返回的字符串中的数据为xml/html格式. 后来经过百度,发现了两种解决方法,第一种是使用webView,webView中专门为了这种情况准 ...
- C#实现多态之一抽象
1. 抽象类.抽象方法.抽象属性的特点 (1) 关键字:abstract (2) 抽象类只能是其他类的基类 (3) 抽象成员必须存在于抽象类中,但抽象类可以没有抽象成员, ...
- 如何为你的美术妹子做Unity的小工具(一)
在上的工具栏添加 也就是这个位置
- PHP开发APP接口
第1章 APP接口简介 - 课程简介 (:) - APP接口介绍 (:) - 客户端APP通信 (:) 最近学习 - 客户端APP通信格式区别 (:) - APP接口做的哪些事儿 (:) 第2章 封装 ...
- [C++]Saving the Universe——Google Code Jam Qualification Round 2008
Google Code Jam 2008 资格赛的第一题:Saving the Universe. 问题描述如下: Problem The urban legend goes that if you ...
- IOS 特定于设备的开发:监测Retina支持
近年来,Apple在其旗舰设备上引入了Retina显示屏.根据Apple的说法,他的像素密度非常高,足以使人眼无法区分单独的像素. UIScreen类提供了一种容易的方式,用于监查当前设备是否提供了内 ...