이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
const int N = ((int)1e8) / 4;
void solve(){
int g, h;
cin >> g >> h;
bitset <N> dp; // if(dp[i]) then we can get R'(i, h)
dp[1] = 1;
int l = h, r = h * 2 -1;
while(true) {
int before = (l - 1) / g; // l'den önce kaç g var
int after = r / g; // r'de kaç tane g var
if(before != after) {
int point = (before + 1) * g;
cout << (point * h + (point == g ? 0 : g)) << " ";
cout << point << "\n";
return;
}
l = l * h;
r = r * h + (h - 1);
}
exit(1);
}
int32_t main(){
fast
int t=1;
cin>>t;
while(t--) 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... |