結果

問題 No.2017 Mod7 Parade
ユーザー rlangevin
提出日時 2023-04-26 12:21:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 76,448 KB
最終ジャッジ日時 2024-11-15 20:20:24
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

K = int(readline())
mod = 10 ** 9 + 7
pre = [0] * 7
pre[0] = 1
inv = pow(9, 5, 7)
for i in range(K):
    D, L = map(int, readline().split())
    dp = [0] * 7
    ten = pow(10, L, 7)
    for j in range(7):
        dp[j] += pre[j]
        nex = j * ten + (ten - 1) * inv * D
        nex %= 7
        dp[nex] += pre[j]
        dp[j] %= mod
        dp[nex] %= mod
    dp, pre = pre, dp

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