結果

問題 No.2017 Mod7 Parade
ユーザー penguinmanpenguinman
提出日時 2021-07-11 01:12:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 79,316 KB
最終ジャッジ日時 2023-09-17 07:56:18
合計ジャッジ時間 7,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,200 KB
testcase_01 AC 76 ms
71,268 KB
testcase_02 AC 74 ms
71,308 KB
testcase_03 AC 376 ms
79,036 KB
testcase_04 AC 285 ms
78,432 KB
testcase_05 AC 238 ms
78,484 KB
testcase_06 AC 397 ms
79,148 KB
testcase_07 AC 145 ms
77,768 KB
testcase_08 AC 275 ms
78,544 KB
testcase_09 AC 171 ms
77,788 KB
testcase_10 AC 273 ms
78,364 KB
testcase_11 AC 337 ms
78,620 KB
testcase_12 AC 311 ms
78,444 KB
testcase_13 AC 446 ms
79,240 KB
testcase_14 AC 443 ms
79,244 KB
testcase_15 AC 445 ms
79,312 KB
testcase_16 AC 444 ms
79,316 KB
testcase_17 AC 448 ms
79,316 KB
testcase_18 AC 426 ms
79,312 KB
testcase_19 AC 353 ms
79,292 KB
testcase_20 AC 73 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
D = [0]*K
L = [0]*K
for i in range(K):
    D[i],L[i] = map(int,input().split())
mod = int(1e9+7)
div = pow(9,5,7)
dp = [[0]*7 for i in range(7)]
dp[0][1] = 1
for i in reversed(range(K)):
    mem = pow(10,L[i],7)
    cp = [[0]*7 for i in range(7)]
    for j in range(7):
        for k in range(7):
            cp[j][k] += dp[j][k]
            cp[j][k] %= mod
            S = (mem*k%7-k)*div%7*D[i]%7+j
            S %= 7
            if S < 0:
                S += 7
            T = mem*k%7
            cp[S][T] += dp[j][k]
            cp[S][T] %= mod
    dp = cp
ans = 0
for i in range(7):
    for j in range(7):
        ans += dp[i][j]*i
        ans %= mod
print(ans)
0