結果

問題 No.2017 Mod7 Parade
ユーザー titiatitia
提出日時 2022-07-23 06:14:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 20,676 KB
最終ジャッジ日時 2023-09-17 22:10:33
合計ジャッジ時間 4,212 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,076 KB
testcase_01 AC 16 ms
7,656 KB
testcase_02 AC 15 ms
7,700 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=10**9+7

K=int(input())
DL=[tuple(map(int,input().split())) for i in range(K)]

DL.reverse()

DP=[[0]*7 for i in range(6)]
# DP[i][j]で、桁数 mod 6がi個、答え mod 7がjとなるものの個数

DP[0][0]=1
P=pow(9,5,7)
Q=[pow(10,i,7) for i in range(10)]
for D,L in DL:
    NDP=[[0]*7 for i in range(6)]

    x=D*(pow(10,L,7)-1)*P%7

    for i in range(6):
        for j in range(7):
            NDP[i][j]+=DP[i][j]
            NDP[(i+L)%6][(j+x*Q[i])%7]+=DP[i][j]

    for i in range(6):
        for j in range(7):
            DP[i][j]=NDP[i][j]%mod

ANS=0
for i in range(6):
    for j in range(7):
        ANS+=DP[i][j]*j
        ANS%=mod

print(ANS)
0