結果
問題 | No.2810 Have Another Go (Hard) |
ユーザー | chro_96 |
提出日時 | 2024-07-13 11:30:36 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,202 bytes |
コンパイル時間 | 453 ms |
コンパイル使用メモリ | 31,552 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-13 11:32:18 |
合計ジャッジ時間 | 101,187 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
ソースコード
#include <stdio.h> void mul_matrix (long long a[][6], long long b[][6], long long ans[][6], long long mod_num) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { ans[i][j] = 0LL; for (int k = 0; k < 6; k++) { ans[i][j] += a[i][k]*b[k][j]; ans[i][j] %= mod_num; } } } return; } void power_matrix (long long a[][6], long long b, long long ans[][6], long long mod_num) { long long wk[6][6] = {}; if (b <= 0LL) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { ans[i][j] = 0LL; } ans[i][i] = 1LL; } return; } if (b%2LL == 1LL) { power_matrix(a, b/2LL, ans, mod_num); mul_matrix(ans, ans, wk, mod_num); mul_matrix(a, wk, ans, mod_num); return; } power_matrix(a, b/2LL, wk, mod_num); mul_matrix(wk, wk, ans, mod_num); return; } int main () { long long n = 0LL; long long m = 0LL; int k = 0; int c[5000] = {}; int res = 0; long long ans[5000] = {}; long long mod_num = 998244353LL; long long total = 0LL; long long wk1[6][6] = {}; long long wk2[6][6] = {}; res = scanf("%lld", &n); res = scanf("%lld", &m); res = scanf("%d", &k); for (int i = 0; i < k; i++) { res = scanf("%d", c+i); } for (int i = 0; i < 5; i++) { wk1[i+1][i] = 1LL; } for (int i = 0; i < 6; i++) { wk1[0][i] = 1LL; } power_matrix(wk1, n*m, wk2, mod_num); for (int i = 0; i < 6; i++) { total += wk2[0][i]; } total %= mod_num; for (int i = 0; i < k; i++) { long long wk3[6][6] = {}; long long wk4[6][6] = {}; for (int j = 0; j < 5; j++) { wk3[j+1][j+1] = 1LL; } power_matrix(wk1, n, wk2, mod_num); mul_matrix(wk2, wk3, wk4, mod_num); power_matrix(wk4, m-1LL, wk2, mod_num); mul_matrix(wk3, wk2, wk4, mod_num); power_matrix(wk1, (long long)c[i], wk2, mod_num); mul_matrix(wk4, wk2, wk3, mod_num); power_matrix(wk1, n-((long long)(c[i]+1)), wk2, mod_num); mul_matrix(wk2, wk3, wk4, mod_num); for (int j = 0; j < 6; j++) { ans[i] += wk4[j][0]*((long long)(6-j)); } printf("%lld\n", (mod_num-ans[i]%mod_num)); } return 0; }