题意:求a,b使得gcd(a,b) = G, lcm(a,b) = L且a最小.
设a=k1*G, b = k2*G,gcd (k1,k2)=0,设k=L/G,枚举一下k1判断互质就好了.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
using namespace std;
long long g, l, a, b;
int main () {
int t;
cin >> t;
while (t--) {
cin >> g >> l;
if (l%g != 0) {
cout << "-1\n";
continue;
}
long long k = l/g;
for (long long i = 1; i*i <= k; i++) {
long long j = k/i;
if (__gcd (i, j) == 1) {
cout << i*g << " " << j*g << "\n";
goto out;
}
}
cout << "-1\n";
out: ;
}
return 0;
}