結果

問題 No.2017 Mod7 Parade
ユーザー rlangevinrlangevin
提出日時 2023-04-26 12:21:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 76,048 KB
最終ジャッジ日時 2024-04-27 16:34:22
合計ジャッジ時間 3,617 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,124 KB
testcase_01 AC 37 ms
51,936 KB
testcase_02 AC 34 ms
51,936 KB
testcase_03 AC 133 ms
75,720 KB
testcase_04 AC 100 ms
75,736 KB
testcase_05 AC 92 ms
76,048 KB
testcase_06 AC 136 ms
75,772 KB
testcase_07 AC 54 ms
68,100 KB
testcase_08 AC 95 ms
75,740 KB
testcase_09 AC 65 ms
72,840 KB
testcase_10 AC 94 ms
75,924 KB
testcase_11 AC 114 ms
75,772 KB
testcase_12 AC 110 ms
75,932 KB
testcase_13 AC 145 ms
75,884 KB
testcase_14 AC 149 ms
75,752 KB
testcase_15 AC 148 ms
75,700 KB
testcase_16 AC 145 ms
75,704 KB
testcase_17 AC 145 ms
75,960 KB
testcase_18 AC 148 ms
75,796 KB
testcase_19 AC 74 ms
75,768 KB
testcase_20 AC 34 ms
52,284 KB
権限があれば一括ダウンロードができます

ソースコード

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