이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |