QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524434#5661. Multi-LadderstyuLD#TL 0ms3660kbC++231.1kb2024-08-19 17:40:272024-08-19 17:40:27

Judging History

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

  • [2024-08-19 17:40:27]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3660kb
  • [2024-08-19 17:40:27]
  • 提交

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];
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] = 1;
        while (tmp--) {
            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;
                    }
                }
            }
        }
        // cout << dp[0][0] << endl;
        tmp = ((((c - 1) + (c - 2) * (c - 2)) * dp[0][0] / (c - 1))) % MOD;
        // cout << tmp << endl;
        ans = (k * (n - 1) * tmp * dp[0][0]) % MOD;
        cout << ans << endl;
    }
    return 0;
}
// ABCDGJM
// A C G M

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
0
-6561
3888
0
0
-875811197
-60270582
102438998
36104191
649694677

result: