QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524457 | #5661. Multi-Ladders | tyuLD# | RE | 0ms | 3588kb | C++23 | 1.3kb | 2024-08-19 18:05:49 | 2024-08-19 18:05:49 |
Judging History
answer
#include <bits/stdc++.h>
// #define N 1000000005
#define int long long
#define MOD 1000000007
#define pii pair<int, int>
#define inf 1e8 + 5
using namespace std;
int dp[1][2], arr[2][2], arr1[1][2];
int fastpow(int x, int y, int p) {
int ans = 1;
int tmp = x * y;
while (p) {
if (p & 1) {
ans *= tmp;
}
p >>= 1;
tmp *= tmp;
}
return ans;
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int n, k, c, ans;
int t;
cin >> t;
while (t--) {
cin >> n >> k >> c;
int tmp = k;
arr[0][0] = c - 2;
arr[1][0] = c - 1;
arr[0][1] = 1;
arr[1][1] = 0;
arr1[0][0] = 0;
arr1[0][1] = c;
for (int i = 0; i < 1; i++) {
for (int j = 0; j < 2; j++) {
for (int l = 0; l < 2; l++) {
dp[i][j] += (arr1[i][l] * arr[l][j]) % MOD;
// dp[i][j] += fastpow(arr1[i][l], arr[l][j], k) % MOD;
}
}
}
// dp[0][0] *= k;
// cout << dp[0][0] << endl;
tmp = ((((c - 1) + (c - 2) * (c - 2))) * dp[0][0] / (c - 1)) % MOD;
ans = (k * (n - 1) * tmp * dp[0][0]) % MOD;
cout << ans << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
1 2 3 3
output:
162
result:
ok single line: '162'
Test #2:
score: -100
Runtime Error
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 0 -11664 5292 0 0 -61348823 686899898 859879194 17612083 -809836975 -948472033 -66056579 -894861499 0 0 0 -995083359