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;
int r(int a, int b) {
if(a < b)return r(b, a);
if(b > 1)return r(a/b, b);
return a;
}
int main () {
int t;
cin >> t;
while(t--) {
int g, h;
cin >> g >> h;
if(g == h) {
cout << g << ' ' << g << endl;
}
else if(h == 2 or g == h*h) {
cout << h*g << ' ' << g << endl;
}
else {
bool check = false;
for(int a = g;a<=10000;a+=g) {
for(int b = g;b<=10000;b+=g) {
if(r(a, b) == h and __gcd(a, b) == g) {
cout << a << ' ' << b << endl;
check = true;
break;
}
}
if(check)break;
}
}
}
}
# | 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... |