이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const ld E = 1e-9;
const ll N = 2010;
ll h, g;
ll R(ll a, ll b){
if (min(a, b) == 1) return max(a, b);
if (b > a)
return R(b / a, a);
else return R(a / b, b);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
// cerr << R(36, 130) << '\n';
// cerr << R(38, 137) << '\n';
// cerr << R(26, 91) << '\n';
// cerr << R(28, 98) << '\n';
// cerr << R(40, 120) << '\n';
//
// return 0;
ll qq; cin >> qq;
for (; qq; qq--){
cin >> g >> h;
if (h <= g){
if (g == h){
cout << g << " " << g << '\n';
continue;
}
ll mx = 1;
for (ll i = g + g; ; i *= 2) {
if (R(i, h) == h) {
// cout << i << " " << i * h + g << '\n';
cout << ll(i) * ll(h) + ll(g) << " " << i << '\n';
break;
}
}
continue;
}
ll beg = g * ((h + g - 1) / g);
for (ll i = g; ; i += g)
if (__gcd(i, beg) == g && R(i, beg) == h){
cout << beg << " " << i << '\n';
break;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
euklid.cpp: In function 'int main()':
euklid.cpp:44:16: warning: unused variable 'mx' [-Wunused-variable]
44 | ll mx = 1;
| ^~
# | 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... |