This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline int R(int a, int b){
if(a < b)return R(b,a);
else if(a >= b and b > 1)return R(a/b,b);
else return a;
}
void solve(){
int g,h;
cin >> g >> h;
if(g == h)cout << h << " " << h << endl;
else if(h == 2)cout << 2*g << " " << g << endl;
else if(g == (h*h))cout << h*h << " " << h*h*h << endl;
else{
for(int i = 1;i;i++){
if(__gcd(i,h) == 1 and R(i*g,h*g) == h){
cout << i*h << " " << h*g << endl;
return;
}
}
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;cin >> testcase;
while(testcase--)solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |