QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#205088#5661. Multi-LaddersAlfehAC ✓1ms3564kbC++14962b2023-10-07 14:50:472023-10-07 14:50:47

Judging History

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

  • [2023-10-07 14:50:47]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3564kb
  • [2023-10-07 14:50:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int sz = 1e5 + 5, mod = 1e9 + 7;
long long binpow(long long a, long long b) {
    a %= mod;
    if(a==0)
        return 0;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int koto(int node, int clr) {
	if(node&1 && clr < 3) return 0;
	int a1 = binpow(clr - 1, node);
	if(node&1) a1 -= clr - 1;
	else a1 += clr - 1;
	a1 %= mod;
	if(a1 < 0) a1 += mod;
	return a1;
}
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t = 1; cin >> t;
	while(t--) {
		int n, k, l; cin >> n >> k >> l;
		if(l < 2) {
			cout << "0\n";
			continue;
		}
		int a1 = (1LL * (l - 2) * (l - 2) % mod + l - 1) % mod;
		int ans1 = binpow(a1, 1LL * (n - 1) * k % (mod - 1));
		cout << 1LL * ans1 * koto(k, l) % mod << "\n";
	}
	return 0; 
}

详细

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3552kb

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