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\) ...
随机推荐
- 如何在gvim中安装autoproto自动显示函数原型
cankao: http://www.vim.org/scripts/script.php?script_id=1553 注意, 在gvim中执行的命令, :foo和:!foo 的区别, 跟vim一样 ...
- HDU 4391 Paint The Wall(分块的区间维护)
题意:给出几个操作,把l-r赋值为z,询问l-r有几个z,其中z < INT_MAX 思路:因为z很大,所以很难直接用线段树去维护.这里可以使用分块来解决.我们可以让每个块用map去储存map[ ...
- 【做题】Codeforces Round #429 (Div. 2) E. On the Bench——组合问题+dp
题目大意是给你n个数,求相邻两数相乘不是完全平方数的排列数. 一开始看到这题的时候,本人便想给相乘为完全平方数的数对建边,然后就写萎了... 后来通过集体智慧发现这个重要性质:对于自然数a,b,c,若 ...
- 【第四十章】Spring Boot 自定义拦截器
1.首先编写拦截器代码 package com.sarnath.interceptor; import javax.servlet.http.HttpServletRequest; import ja ...
- 记录一下 ajax的基础传送
传数据 var json = $("#form").serializeObject(); $.ajax({ url: "/getUser", type: &qu ...
- WSL及Linux入门
win10内置linux子系统(Windows Subsystem for Linux),可以不用安装Vmware等虚拟机学习linux啦. wsl开启方式 设置打开开发人员模式. 控制面板-程序和功 ...
- 题解—— 洛谷 p1993 小K的农场(差分约束&负环判断)
看到题就可以想到差分约束 判断负环要用dfs,bfs-spfa会TLE 4个点 bfs-spfa #include <cstdio> #include <algorithm> ...
- 【Hadoop 分布式部署 八:分布式协作框架Zookeeper架构功能讲解 及本地模式安装部署和命令使用 】
What is Zookeeper 是一个开源的分布式的,为分布式应用提供协作服务的Apache项目 提供一个简单的原语集合,以便与分布式应用可以在他之上构建更高层次的同步服务 设计非常简单易于编 ...
- SQL语句执行的顺序机制
From Where Group by Having Select 表达式 Distinct ORDER BY TOP/OFFSET-FETCH
- Kubernetes之总体了解
Kubernetes:架构.基本概念.用于总体了解 Kubernetes系列之介绍篇:优势.用途 Kubernetes核心概念总结