QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183971#5661. Multi-LaddersMaGnsi0#WA 1ms3596kbC++17903b2023-09-20 05:24:302023-09-20 05:24:31

Judging History

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

  • [2023-09-20 05:24:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2023-09-20 05:24:30]
  • 提交

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;
        if (m < 2) {
            cout << 0 << "\n";
            continue;
        }
        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;
        cout << ans << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3596kb

input:

1
2 3 3

output:

324

result:

wrong answer 1st lines differ - expected: '162', found: '324'