QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#807816#9864. Coinhxu10Compile Error//Python31.0kb2024-12-10 12:26:272024-12-10 12:26:29

Judging History

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

  • [2024-12-10 12:26:29]
  • 评测
  • [2024-12-10 12:26:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void solve() {
    long long n, k;
    cin >> n >> k;

    long long curr = 1;
    long long ans = -1;

    while (curr <= n) {
        long long b = ((curr - 1) / k) * k + k;
        long long step = b / k;
        if (b > n) {
            ans = curr + ((n - curr) / step) * step;
            break;
        }

        curr += ((b - curr) / step) * step;

        long long front = curr + step + 1;
        long long rear = curr + 2 * step  + 1;

        while (front < rear) {
            long long mid = (front + rear) / 2;
            long long should = ((mid - 1) / k) + 1;
            long long actual = mid - curr;
            if (actual < should) {
                front = mid + 1;
            } else {
                rear = mid;
            }
        }

        ans = curr;
        curr = front;
    }

    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    for (int t = 1; t <= T; t++) {
        solve();
    }

    return 0;
}

Details

  File "answer.code", line 2
    using namespace std;
          ^^^^^^^^^
SyntaxError: invalid syntax