QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#848954#9864. CoinhhoppitreeWA 1ms3824kbC++23719b2025-01-09 10:57:412025-01-09 10:57:43

Judging History

你现在查看的是最新测评结果

  • [2025-01-09 10:57:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2025-01-09 10:57:41]
  • 提交

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;
}

詳細信息

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'