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 std::vector;
using std::array;
using std::pair;
using std::tuple;
using i64 = std::int64_t;
constexpr i64 ceil_div(const i64 a, const i64 b) {
return (a + b - 1) / b;
}
pair<i64, i64> solve(const i64 G, const i64 H) {
i64 a = H, b = H;
while (a < G) a *= H;
b = ceil_div(a * b, G) * G;
return {a * b + G, b};
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int Q;
std::cin >> Q;
while (Q--) {
i64 G, H;
std::cin >> G >> H;
const auto [a, b] = solve(G, H);
std::cout << a << ' ' << b << '\n';
}
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... |