結果

問題 No.2017 Mod7 Parade
ユーザー asumo0729asumo0729
提出日時 2022-07-27 22:59:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 88,536 KB
最終ジャッジ日時 2023-09-24 11:30:26
合計ジャッジ時間 8,028 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,376 KB
testcase_01 AC 74 ms
71,228 KB
testcase_02 AC 71 ms
71,196 KB
testcase_03 AC 347 ms
86,004 KB
testcase_04 AC 272 ms
83,484 KB
testcase_05 AC 235 ms
81,820 KB
testcase_06 AC 367 ms
87,236 KB
testcase_07 AC 150 ms
79,104 KB
testcase_08 AC 256 ms
82,892 KB
testcase_09 AC 176 ms
80,088 KB
testcase_10 AC 265 ms
83,024 KB
testcase_11 AC 321 ms
84,944 KB
testcase_12 AC 319 ms
84,380 KB
testcase_13 AC 445 ms
88,188 KB
testcase_14 AC 385 ms
88,376 KB
testcase_15 AC 382 ms
88,536 KB
testcase_16 AC 412 ms
88,204 KB
testcase_17 AC 384 ms
88,456 KB
testcase_18 AC 380 ms
88,160 KB
testcase_19 AC 387 ms
88,228 KB
testcase_20 AC 67 ms
71,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
dp = [[0 for _ in range(7)] for _ in range(6)]
dp[0][0] = 1
mod = 10 ** 9 + 7
mod7 = [1,3,2,6,4,5]
DL = [list(map(int, input().split())) for _ in range(K)]
for i in range(K):
    D, L = DL[-1 - i]
    newdp = [[0 for _ in range(7)] for _ in range(6)]
    for j in range(6):
        for k in range(7):
            newdp[j][k] += dp[j][k]
    for j in range(6):
        add = 0
        for k in range(L % 6):
            add = (add + mod7[(j + k) % 6] * D) % 7
        for k in range(7):
            newdp[(j + L) % 6][(k + add) % 7] += dp[j][k]
            newdp[(j + L) % 6][(k + add) % 7] %= mod
    dp = newdp

ans = 0
for i in range(6):
    for j in range(7):
        ans += dp[i][j] * j
        ans %= mod

print(ans)
exit()
0