QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#848954 | #9864. Coin | hhoppitree | WA | 1ms | 3824kb | C++23 | 719b | 2025-01-09 10:57:41 | 2025-01-09 10:57:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
long long g(long long x, long long y) {
long long res = 0;
while (x != 1) {
long long v = (x + y - 1) / y, t = min((x - ((v - 1) * y)) / v + 1, (x - 1) / v);
x -= v * t;
res += t;
}
return res;
}
long long f(long long x, long long y) {
--x;
long long res = 1;
while (y) {
long long v = (res + x - 1) / x, t = min((x * v - res) / v + 1, y);
res += v * t;
y -= t;
}
return res;
}
signed main() {
int T; scanf("%d", &T);
while (T--) {
long long n, m; scanf("%lld%lld", &n, &m);
printf("%lld\n", f(m, g(n, m)));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3824kb
input:
4 6 2 8 3 10000 2 1919810 114514
output:
4 5 8192 1919788
result:
wrong answer 2nd numbers differ - expected: '8', found: '5'