QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#737283#7026. Let the Flames BeginSGColin#AC ✓693ms3876kbC++171023b2024-11-12 15:19:262024-11-12 15:19:27

Judging History

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

  • [2024-11-12 15:19:27]
  • 评测
  • 测评结果:AC
  • 用时:693ms
  • 内存:3876kb
  • [2024-11-12 15:19:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

inline ll rd() {
    ll x = 0;
    bool f = 0;
    char c = getchar();
    for (; !isdigit(c); c = getchar()) f |= (c == '-');
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    return f ? -x : x;
}

#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

int testcase;

inline void work() {
    printf("Case #%d: ", ++testcase);
    ll n = rd(), m = rd(), k = rd();
    if (k == 1) {printf("%lld\n", m); return;}
    ll nn = n - m + 1;
    ll ans = (k - 1) % nn + 1;
    while (nn < n) {
        ll num = min(n - nn, (nn - ans) / (k - 1));
        ans += num * k;
        nn += num;
        if (nn == n) break;
        ++nn;
        ans = (ans + k - 1) % nn + 1;
    }
    printf("%lld\n", ans);
}

int main() {
    per(t, rd(), 1) work();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3876kb

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:

Case #1: 2
Case #2: 4
Case #3: 6
Case #4: 8
Case #5: 10
Case #6: 3
Case #7: 7
Case #8: 1
Case #9: 9
Case #10: 5
Case #11: 3
Case #12: 6
Case #13: 9
Case #14: 2
Case #15: 7
Case #16: 1
Case #17: 8
Case #18: 5
Case #19: 10
Case #20: 4

result:

ok 20 lines

Test #2:

score: 0
Accepted
time: 654ms
memory: 3816kb

input:

1000
999999999999992561 159 395327336264586619
442108849746740138 442108849746736034 460
999999999999992483 170 493046129512466597
999999999999994068 441 350960072694194744
999999999999995777 999999999999990118 67
999999999999991275 999999999999983373 331
999999999999990404 999999999999985608 429
99...

output:

Case #1: 857046466069738524
Case #2: 294578226925711387
Case #3: 817842017119952395
Case #4: 773392058140829462
Case #5: 522542636681279298
Case #6: 855114113325419851
Case #7: 21226015093289476
Case #8: 233100
Case #9: 641511906156530773
Case #10: 93961109024303404
Case #11: 230107545980257170
Case...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 693ms
memory: 3844kb

input:

1
999999999999999944 999999999999999890 2000000

output:

Case #1: 164945406307572169

result:

ok single line: 'Case #1: 164945406307572169'