結果

問題 No.2017 Mod7 Parade
ユーザー lloyzlloyz
提出日時 2022-07-22 23:43:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 753 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 83,308 KB
最終ジャッジ日時 2023-09-17 12:57:40
合計ジャッジ時間 11,144 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,320 KB
testcase_01 AC 77 ms
71,024 KB
testcase_02 AC 74 ms
71,440 KB
testcase_03 AC 685 ms
82,248 KB
testcase_04 AC 445 ms
80,764 KB
testcase_05 AC 358 ms
80,488 KB
testcase_06 AC 662 ms
82,696 KB
testcase_07 AC 177 ms
78,036 KB
testcase_08 AC 426 ms
80,796 KB
testcase_09 AC 230 ms
78,488 KB
testcase_10 AC 431 ms
80,892 KB
testcase_11 AC 549 ms
81,840 KB
testcase_12 AC 499 ms
81,116 KB
testcase_13 AC 750 ms
82,412 KB
testcase_14 AC 753 ms
82,684 KB
testcase_15 AC 746 ms
82,744 KB
testcase_16 AC 748 ms
82,616 KB
testcase_17 AC 749 ms
82,840 KB
testcase_18 AC 702 ms
83,308 KB
testcase_19 AC 199 ms
82,836 KB
testcase_20 AC 75 ms
71,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k = int(input())
D = []
for _ in range(k):
    d, l = map(int, input().split())
    r = (pow(10, l, 7 * 9) - 1) // 9 * d % 7
    D.append((r, l))

mod = 10**9 + 7
ans = 0
DP = [0 for _ in range(7)]
for r, l in D:
    NDP = [0 for _ in range(7)]
    ans += r
    ans %= mod
    NDP[r] += 1
    for i in range(7):
        if DP[i]:
            nr = (i * pow(10, l, 7) + r) % 7
            ans += DP[i] * nr
            ans %= mod
            NDP[nr] += DP[i]
            NDP[nr] %= mod
            NDP[i] += DP[i]
            NDP[i] %= mod
    DP = NDP
print(ans)
0