QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183969#5661. Multi-LaddersMaGnsi0#WA 1ms3648kbC++17880b2023-09-20 05:16:142023-09-20 05:16:14

Judging History

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

  • [2023-09-20 05:16:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2023-09-20 05:16:14]
  • 提交

answer

/**
 *    author:  MaGnsi0
 *    created: 19.09.2023 23:58:10
**/
#include <bits/stdc++.h>

using namespace std;

const int64_t MOD = 1e9 + 7;

int64_t power(int64_t b, int64_t p) {
    int64_t ans = 1; b %= MOD;
    while (p) {
        if (p & 1) { ans = ans * b % MOD; }
        b = b * b % MOD;
        p /= 2;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int64_t n, k, m;
        cin >> n >> k >> m;
        int64_t val = m * (m - 1) % MOD; 
        int64_t x = (2 * (m - 1) + (m - 2) * (m - 3) % MOD + MOD - 1) % MOD;
        x = power(x, n - 1);
        int64_t ans = val * x % MOD * power(m - 1, k - 2) % MOD * power(x, k - 1) % MOD;
        if (k & 1) { ans = ans * power(m - 1, MOD - 2) % MOD; }
        cout << ans << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3648kb

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3584kb

input:

20
2 3 3
1 3 3
10 3 0
10 3 2
1 21 2
1 22 0
2000 15000 2000
12000 30000 200000
1000000000 3 3
2 1000000000 3
2 3 100000000
1000000000 1000000000 10
1000000000 3 100000000
2 1000000000 100000000
1 1000000000 10
1 1000000000 100000000
1 1000 100000000
1000000000 1000000000 0
1000000000 1000000000 1
100...

output:

162
6
0
2
2
0
664789504
176952782
52489881
372717338
304930780
690071752
422872637
661162175
325614908
852118222
991930477
0
0
943177668

result:

wrong answer 4th lines differ - expected: '0', found: '2'