結果
問題 | No.578 3 x N グリッド上のサイクルのサイズ(easy) |
ユーザー | Ryuhei Mori |
提出日時 | 2017-06-01 18:03:22 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,468 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 30,296 KB |
実行使用メモリ | 4,348 KB |
最終ジャッジ日時 | 2023-10-23 18:55:47 |
合計ジャッジ時間 | 2,519 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
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 | - |
ソースコード
#include <stdio.h> const int mod = 1000000007; int tmp[2][10][10]; const int T[10][10] = { {1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 1, 1, 1, 0, 0, 0, 1, 0, 1}, {0, 1, 1, 1, 1, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 1, 1, 1, 0, 1, 1}, {0, 0, 1, 1, 1, 1, 0, 0, 0, 1}, {0, 0, 1, 1, 1, 1, 1, 0, 0, 1}, {0, 0, 0, 1, 0, 1, 1, 1, 0, 1}, {0, 0, 0, 1, 0, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 0, 0, 1, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, }; const int TT[10][10] = { {0, 3, 4, 5, 3, 4, 3, 6, 0, 0}, {0, 2, 3, 4, 0, 0, 0, 3, 0, 1}, {0, 3, 2, 3, 3, 4, 0, 0, 0, 2}, {0, 4, 3, 2, 4, 3, 4, 0, 3, 3}, {0, 0, 3, 4, 2, 3, 0, 0, 0, 1}, {0, 0, 4, 3, 3, 2, 3, 0, 0, 2}, {0, 0, 0, 4, 0, 3, 2, 3, 0, 1}, {0, 0, 0, 3, 0, 0, 0, 4, 0, 0}, {0, 3, 0, 0, 0, 0, 3, 0, 4, 2}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, }; int Ti[1000001][10][10]; void mult(const int A[10][10], const int B[10][10], int C[10][10]){ int i, j, k; for(i=0;i<10;i++){ for(j=0;j<10;j++){ long long int tmp = 0; for(k=0;k<10;k++){ tmp = (tmp + (long long int) A[i][k] * B[k][j]) % mod; } C[i][j] = tmp; } } } int main(){ int i, j, ans; int n; scanf("%d", &n); for(i=0;i<10;i++){ for(j=0;j<10;j++){ Ti[0][i][j] = i == j; } } for(i=0;i<n;i++){ mult(Ti[i], T, Ti[i+1]); } ans = 0; for(i=0;i<=n;i++){ mult(Ti[i], TT, tmp[0]); mult(tmp[0], Ti[n-i], tmp[1]); ans += tmp[1][0][9]; if(ans >= mod) ans -= mod; } printf("%d\n", ans); return 0; }