QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#650151#5661. Multi-LaddersXfJbUhpyzgaW#AC ✓1ms3692kbC++14715b2024-10-18 13:29:052024-10-18 13:29:06

Judging History

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

  • [2024-10-18 13:29:06]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3692kb
  • [2024-10-18 13:29:05]
  • 提交

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, 1ll * (n - 1) * k % (M - 1));
        cout << (ans % M + M) % M << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3568kb

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
52489881
53690844
176686901
218103365
558243892
991895211
693053429
883715672
80402569
0
0
311752813

result:

ok 20 lines