uva11388
因为a,b整除gcd(a,b),lcm(a,b)又整除a,b,因此如果lcm不整除gcd就是-1;否则的话,lcm=a*b/gcd。而a不能小于gcd,因此a就取gcd,b取lcm。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
using namespace std;
const double EPS=1e-;
typedef long long lon;
const lon SZ=,INF=0x7FFFFFFF,mod=;
int n,m; void init()
{ } void work()
{ } int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
lon casenum;
cin>>casenum;
//cout<<casenum<<endl;
for(lon time=;time<=casenum;++time)
//for(lon time=1;cin>>n>>m;++time)
{
cin>>n>>m;
if(n>m)swap(n,m);
if(m%n==)cout<<n<<" "<<m<<endl;
else cout<<-<<endl;
}
return ;
}
uva11388的更多相关文章
- 洛谷 UVA11388 GCD LCM
UVA11388 GCD LCM Description of the title PDF The GCD of two positive integers is the largest intege ...
- UVA11388 GCD LCM(数论)
题目链接. 题意: 给定两个数,一个G,一个L,找出两个数a,b(a<=b),使得这两个数的最大公约数为G,最小公倍数为L,且(a最小). 分析: 当a,b存在时,a一定为G. 自己证了一下,数 ...
- UVA11388 GCD LCM1 2 -1
题目: 给你两个数G和L,求a和b,他们的最大公约数为G和最小公倍数为L,输出a最小时的a和b.如果不存在在输出-1. Sample Input 2 1 2 3 4 Output for Samp ...
- UVA11388 GCD LCM
(链接点这儿) 题目: The GCD of two positive integers is the largest integer that divides both the integers w ...
- 题解 UVa11388
题目大意 \(T\) 组数据,每组数据给定两个整数 \(G,L\),输出数对 \(x,y\) 满足 \(GCD(x,y)=G,LCM(x,y)=L\) 且 \(x\) 最小.若无解则输出 \(-1\) ...
随机推荐
- lnmp部署知乎出现403
查看错误日志: [root@web01 /]# tailf /var/log/nginx/error.log 2019/01/16 19:02:06 [error] 10023#10023: *8 ...
- Linux服务器搭建Nexus-Maven私服(适合新手比较基础)
背景 在使用maven构建项目的时候,几乎都会涉及到一个“私服”的概念,那么到底什么是私服?使用私服有能够带来哪些益处? 私服:私服是指私有服务器,是架设在局域网的一种特殊的远程仓库,目的是代理远程仓 ...
- Bootstrap3基础 img-responsive 响应式图片
内容 参数 OS Windows 10 x64 browser Firefox 65.0.2 framework Bootstrap 3.3.7 editor ...
- cygwin下如何运行crontab定时脚本?
1. 安装cron服务(如果不能启动,使用管理员身份运行cygwin) cygrunsrv -I cron -p /usr/sbin/cron -a -D -I 是安装 cron是服务名 -p /us ...
- LVM基本应用,扩展及缩减实现
一.基本概念 如上图所示:底层PV(物理卷可能是硬盘设备,分区或RAID等),一个或多个PV组织成一个VG(卷组),卷组是不能直接格式化使用的,所以在VG之上,还需要创建LV进行格式化使用.VG在逻辑 ...
- word2010使用记录
安装时提示: installer无法更新被保护的一个或多个文件, 解决方法是: 将三个dll文件,放在 c:\program files\common files\ms shared\web serv ...
- js 二叉树删除最大值和最小值
//删除最小值function delMinNode (root){ if(!root) { return false; } var current = root; if (current.left ...
- Perceptual Losses for Real-Time Style Transfer and Super-Resolution and Super-Resolution 论文笔记
Perceptual Losses for Real-Time Style Transfer and Super-Resolution and Super-Resolution 论文笔记 ECCV 2 ...
- Template 制作模版
直接写在选项里的模板 直接在构造器里的template选项后边编写.这种写法比较直观,但是如果模板html代码太多,不建议这么写. var vm = new Vue({ el:"#app&q ...
- Java基础 【Arrays 类的使用】
package com.zuoyan.sort; import java.util.Arrays; public class ArraysClassDemo { public static void ...