結果

問題 No.2017 Mod7 Parade
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-07-30 19:18:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 89,416 KB
最終ジャッジ日時 2023-09-27 21:04:20
合計ジャッジ時間 9,091 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,296 KB
testcase_01 AC 67 ms
71,228 KB
testcase_02 AC 66 ms
71,300 KB
testcase_03 AC 410 ms
86,688 KB
testcase_04 AC 303 ms
84,108 KB
testcase_05 AC 255 ms
82,288 KB
testcase_06 AC 434 ms
87,992 KB
testcase_07 AC 141 ms
78,440 KB
testcase_08 AC 287 ms
83,184 KB
testcase_09 AC 178 ms
79,508 KB
testcase_10 AC 298 ms
83,156 KB
testcase_11 AC 386 ms
85,672 KB
testcase_12 AC 349 ms
84,724 KB
testcase_13 AC 492 ms
89,416 KB
testcase_14 AC 492 ms
89,136 KB
testcase_15 AC 484 ms
89,172 KB
testcase_16 AC 490 ms
89,272 KB
testcase_17 AC 491 ms
89,260 KB
testcase_18 AC 490 ms
89,356 KB
testcase_19 AC 498 ms
89,264 KB
testcase_20 AC 67 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
dl = []
for i in range(k):
    dl.append(tuple(map(int,input().split())))
dp = [[0] * 7 for _ in range(6)]
dp[0][0] = 1
mod = 10 ** 9 + 7
for d,l in dl[::-1]:
    n_dp = [[0] * 7 for _ in range(6)]
    p = (l%6)
    if p == 0:p = 6
    val = int((str(d) * p)) % 7
    for i in range(6):
        for j in range(7):
            n_dp[i][j] += dp[i][j]
            val2 = (pow(10,i,7)*val) % 7
            n_dp[(i+p)%6][(j+val2)%7] += dp[i][j]
            n_dp[(i+p)%6][(j+val2)%7] %= mod
    dp = n_dp

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