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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll R(ll a, ll b) {
if (a<b) swap(a,b);
if (b==1) return a;
return R(a/b, b);
}
void solve(ll g, ll h) {
ll hpw=1;
while (hpw <= g) {
hpw *= h;
}
ll b = g*( (hpw+g-1)/g );
ll a = h*b + g;
cout<<a<<" "<<b<<"\n";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t;
cin>>t;
while (t--) {
ll g,h;
cin>>g>>h;
solve(g,h);
}
return 0;
}
# | 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... |