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;
}
int g,h;
void solve(){
cin >> g >> h;
int l = h , r = 2 * h - 1;
while(true){
if((l + (g - l%g)) <= r){
int k = (l + (g - l%g)) / g;
if(R(g*k,g*k*h+g) == h){
cout << g * k << " " << g * k * h + g << endl;
return;
}
}
l *= h;
r *= h;
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase;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... |