結果

問題 No.2017 Mod7 Parade
ユーザー H3PO4H3PO4
提出日時 2022-07-22 21:57:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 88,756 KB
最終ジャッジ日時 2023-09-17 09:54:59
合計ジャッジ時間 4,964 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,460 KB
testcase_01 AC 74 ms
71,528 KB
testcase_02 AC 73 ms
71,120 KB
testcase_03 AC 200 ms
85,988 KB
testcase_04 AC 164 ms
83,276 KB
testcase_05 AC 145 ms
82,380 KB
testcase_06 AC 212 ms
87,036 KB
testcase_07 AC 103 ms
78,400 KB
testcase_08 AC 155 ms
81,948 KB
testcase_09 AC 114 ms
78,680 KB
testcase_10 AC 157 ms
82,008 KB
testcase_11 AC 184 ms
84,832 KB
testcase_12 AC 175 ms
84,336 KB
testcase_13 AC 231 ms
87,880 KB
testcase_14 AC 229 ms
87,448 KB
testcase_15 AC 228 ms
87,884 KB
testcase_16 AC 231 ms
87,788 KB
testcase_17 AC 230 ms
88,164 KB
testcase_18 AC 220 ms
87,464 KB
testcase_19 AC 153 ms
88,756 KB
testcase_20 AC 73 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline

K = int(input())
DL = tuple(tuple(map(int, input().split())) for _ in range(K))

dp = [0] * 7
dp[0] = 1
MOD = 10 ** 9 + 7
i9 = pow(9, 7 - 2, 7)
for d, l in DL:
    new_dp = dp.copy()
    p = pow(10, l, 7)
    for i in range(7):
        j = i * p + (p - 1) * i9 * d
        j %= 7
        new_dp[j] += dp[i]
    dp = new_dp
    for i in range(7):
        dp[i] %= MOD
dp[0] -= 1

ans = 0
for i in range(1, 7):
    ans += dp[i] * i
ans %= MOD
print(ans)
0