結果

問題 No.2017 Mod7 Parade
ユーザー 👑 tamatotamato
提出日時 2022-07-22 21:57:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 83,532 KB
最終ジャッジ日時 2023-09-17 09:52:46
合計ジャッジ時間 5,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,236 KB
testcase_01 AC 74 ms
71,424 KB
testcase_02 AC 75 ms
71,376 KB
testcase_03 AC 224 ms
82,472 KB
testcase_04 AC 180 ms
80,612 KB
testcase_05 AC 157 ms
79,328 KB
testcase_06 AC 239 ms
82,340 KB
testcase_07 AC 111 ms
77,508 KB
testcase_08 AC 175 ms
80,384 KB
testcase_09 AC 125 ms
77,920 KB
testcase_10 AC 174 ms
80,104 KB
testcase_11 AC 208 ms
82,292 KB
testcase_12 AC 196 ms
81,492 KB
testcase_13 AC 261 ms
82,452 KB
testcase_14 AC 262 ms
82,540 KB
testcase_15 AC 261 ms
82,188 KB
testcase_16 AC 260 ms
82,008 KB
testcase_17 AC 260 ms
82,212 KB
testcase_18 AC 258 ms
82,576 KB
testcase_19 AC 255 ms
83,532 KB
testcase_20 AC 72 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    DL = []
    for _ in range(N):
        d, l = map(int, input().split())
        DL.append((d, l % 6))

    mod10 = [pow(10, i, 7) for i in range(6)]

    dp = [[0] * 6 for _ in range(7)]
    dp[0][0] = 1
    for i in range(N - 1, -1, -1):
        dp_new = [[0] * 6 for _ in range(7)]
        d, l = DL[i]
        if l:
            dd = int(str(d) * l) % 7
        else:
            dd = 0
        for j in range(7):
            for k in range(6):
                dp_new[j][k] = (dp_new[j][k] + dp[j][k]) % mod
                dp_new[(j + dd * mod10[k]) % 7][(k + l) % 6] = (dp_new[(j + dd * mod10[k]) % 7][(k + l) % 6] + dp[j][k])%mod
        dp = dp_new
    ans = 0
    for j in range(7):
        for k in range(6):
            ans = (ans + (j * dp[j][k]) % mod) % mod
    print(ans)


if __name__ == '__main__':
    main()
0