QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650147#5661. Multi-LaddersXfJbUhpyzgaW#TL 0ms3696kbC++14699b2024-10-18 13:27:232024-10-18 13:27:24

Judging History

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

  • [2024-10-18 13:27:24]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3696kb
  • [2024-10-18 13:27:23]
  • 提交

answer

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

using ll = long long;
const int M = 1e9 + 7;
int power(int x, int y) {
    int ans = 1;
    for (; y; y >>= 1, x = 1ll * x * x % M)
        if (y & 1)
            ans = 1ll * ans * x % M;
    return ans;
}

int main() {
    int T, n, k, c;
    for (cin >> T; T; T--) {
        cin >> n >> k >> c;
        if (c < 2) { cout << "0\n"; continue; }
        ll ans = 1ll * ((k & 1 ? M - 1 : 1) + power(c - 1, k - 1)) * power(c, M - 2) % M;
        ans = ans % M * c % M * (c - 1) % M;
        int t = (1ll * (c - 2) * (c - 2) + c - 1) % M;
        ans = ans * power(t, (n - 1) * k);
        cout << (ans % M + M) % M << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: -100
Time Limit Exceeded

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
0
0
0
349400141
243010659

result: