結果

問題 No.2017 Mod7 Parade
ユーザー 👑 rin204rin204
提出日時 2022-07-22 21:44:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 77,372 KB
最終ジャッジ日時 2023-09-17 09:28:09
合計ジャッジ時間 4,150 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,196 KB
testcase_01 AC 73 ms
71,236 KB
testcase_02 AC 76 ms
71,236 KB
testcase_03 AC 147 ms
77,176 KB
testcase_04 AC 132 ms
77,156 KB
testcase_05 AC 125 ms
77,200 KB
testcase_06 AC 151 ms
77,236 KB
testcase_07 AC 99 ms
77,140 KB
testcase_08 AC 123 ms
77,204 KB
testcase_09 AC 111 ms
77,280 KB
testcase_10 AC 123 ms
77,372 KB
testcase_11 AC 140 ms
77,204 KB
testcase_12 AC 131 ms
77,124 KB
testcase_13 AC 150 ms
77,164 KB
testcase_14 AC 158 ms
77,180 KB
testcase_15 AC 157 ms
77,316 KB
testcase_16 AC 160 ms
77,172 KB
testcase_17 AC 153 ms
77,220 KB
testcase_18 AC 150 ms
77,116 KB
testcase_19 AC 137 ms
77,108 KB
testcase_20 AC 71 ms
71,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

k = int(input())
dp = [0] * 7
dp[0] = 1
for _ in range(k):
    d, l = map(int, input().split())
    l %= 6
    times = pow(10, l, 7)
    plus = 0
    for _ in range(l):
        plus += d
        d *= 10
    plus %= 7
    ndp = dp[:]
    for i in range(7):
        ndp[(i * times + plus) % 7] += dp[i]
        ndp[i] %= MOD
    dp = ndp
ans = sum(i * d for i, d in enumerate(dp))
print(ans % MOD)

0