QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#533027#5661. Multi-Laddersttbchimbu999#WA 0ms3852kbC++141.7kb2024-08-25 16:05:412024-08-25 16:05:45

Judging History

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

  • [2024-08-25 16:05:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3852kb
  • [2024-08-25 16:05:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define matrix vector<vector<int> >
const int M = 1e9 + 7;
matrix operator *(const matrix &a, const matrix &b) {
	matrix c;
	c.resize(a.size());
	for (int i = 0; i < (int)a.size(); ++i) {
		c[i].resize(b[0].size(), 0);
		for (int j = 0; j < (int)b[0].size(); ++j) {
			for (int z = 0; z < (int)a[0].size(); ++z) {
				c[i][j] = (c[i][j] + 1LL * a[i][z] * b[z][j]) % M;
			}
		}
	}
	return c;
}
matrix unit(int n) {
	matrix ans(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		ans[i][i] = 1;
	}
	return ans;
}
matrix fpow(matrix a, long long b, int M = ::M) {
	matrix ans = unit(a.size());
	while (b) {
		if (b & 1) ans = ans * a;
		b >>= 1;
		a = a * a;
	}
	return ans;
}
int fpow(int a, long long b, int M = ::M) {
	int ans = 1;
	while (b) {
		if (b & 1) ans = 1LL * ans * a % M;
		a = 1LL * a * a % M;
		b >>= 1;
	}
	return ans;
}
void solve() {
	int n, k, l;
	cin >> n >> k >> l;
	if (l < k) {
		cout << 0 << '\n';
		return;
	}
	matrix f = {{1LL * l * (l - 1) % M, 0LL, 1LL * l * (l - 1) % M * (l - 2) % M, 1LL * l * (l - 1) % M}};
	matrix m = {
		{0, 0, 0, 0},
		{0, 0, 0, 0},
		{1, 0, l - 2, 1},
		{0, 1, l - 1, 0}
	};
	int ans = (f * fpow(m, k - 3 + 1))[0][0];
	int tmp = fpow((1LL * (l - 1) * (l - 1) - l + 2) % M, 1LL * (n - 1) * k);
	ans = 1LL * ans * tmp % M;
	cout << ans << '\n';
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef LOCAL
	    // freopen("TEST.inp", "r", stdin);
	    // freopen("TEST.out", "w", stdout);
    #else
    	// freopen("TEST.inp", "r", stdin);
    	// freopen("TEST.out", "w", stdout);
    #endif
	int L;
	cin >> L;
	while (L--) {
		solve();
	}
    return 0;
}

詳細信息

Test #1:

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

input:

1
2 3 3

output:

162

result:

ok single line: '162'

Test #2:

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

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
0
243010659
52489881
0
176686901
0
558243892
0
0
0
80402569
0
0
0

result:

wrong answer 7th lines differ - expected: '349400141', found: '0'