QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#838847#9864. CoinlxllxsWA 0ms3532kbC++201.1kb2025-01-01 02:20:032025-01-01 02:20:03

Judging History

This is the latest submission verdict.

  • [2025-01-01 02:20:03]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3532kb
  • [2025-01-01 02:20:03]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
#define int long long
#define endl '\n'
typedef unsigned long long ull;
typedef long long ll;
const int N = 2e5 + 5, M = 2e5 + 5, LGN = 20, mod = 998244353, B = 131, inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f, P = 1000000711;
int n, k;

int calc(int x, int ct) {
    int res = x / k * ct, p = x % k;
    if (p) {
        int d = x / k + 1;
        res += min((p - 1) / d + 1, ct);
    }
    return x - res;
}

int f(int x) {
    if (x == 1)return 1;
    int pt = (x + k - 1) / k, l = 1, r = (x - 1) / pt;
    while (l < r) {
        int mid = l + r >> 1;
        if ((x - pt * mid + k - 1) / k < pt)r = mid;
        else l = mid + 1;
    }
    int p = f(x - pt * l), ct = l;
    l = 1, r = x;
    while (l < r) {
        int mid = l + r >> 1;
        if (calc(mid, ct) >= p)r = mid;
        else l = mid + 1;
    }
    return l;
}

void lxllxs() {
    cin >> n >> k;
    cout << f(n) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t = 1;
//    cin >> t;
    while (t--)lxllxs();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

4
6 2
8 3
10000 2
1919810 114514

output:

4

result:

wrong answer Answer contains longer sequence [length = 4], but output contains 1 elements