QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#763177#7026. Let the Flames BeginxuchengTL 0ms0kbC++141016b2024-11-19 18:42:252024-11-19 18:42:25

Judging History

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

  • [2024-11-19 18:42:25]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-19 18:42:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long

void solve() {
    int n, m, k;
    cin >> n >> m >> k;

    int p = n - m + 1;
    int ans = (k - 1) % p;
    if (m < k) {
        for (int i = 2; i <= m; i ++ ) {
            ans = (ans + k) % (++ p);
        }
    } else {
        int a = n - m + 1;
        if (k == 1) {
            cout << m << "\n";
            return;
        }
        while (a < n) {
            int x = (int)(ceil(1.0 * (a - ans)) / (k - 1));
            if (a + x > n) {
                x = n - a;
            }
            p = a + x;
            ans = (ans + x * k) % p;
            a = a + x;
        }
    }
    cout << ans + 1 << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int TestCaseNumber = 1;
    cin >> TestCaseNumber;

    for (int i = 1; i <= TestCaseNumber; i ++ ) {
        cout << "Case #" << i << ": ";
        solve(); 
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

20
10 1 2
10 2 2
10 3 2
10 4 2
10 5 2
10 6 2
10 7 2
10 8 2
10 9 2
10 10 2
10 1 3
10 2 3
10 3 3
10 4 3
10 5 3
10 6 3
10 7 3
10 8 3
10 9 3
10 10 3

output:


result: