标签:const cstring uva main while ring 思维 vector lcm
两个数的最小公倍数和最大公约数肯定是倍数关系
然后又让求使得a最小 因为 a = m * gcd
令m = 1 时 a取得最小 即gcd
则b = lcm
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <cmath> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; const int maxn = 10010, INF = 0x7fffffff; int main() { int T; int n, m; cin>> T; while(T--) { cin>> n >> m; if(m % n == 0) cout<< n << " " << m <<endl; else cout<< -1 <<endl; } return 0; }
标签:const cstring uva main while ring 思维 vector lcm
原文地址:https://www.cnblogs.com/WTSRUVF/p/9315928.html