結果

問題 No.2017 Mod7 Parade
ユーザー penguinmanpenguinman
提出日時 2021-07-11 01:01:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 666 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 175,300 KB
最終ジャッジ日時 2023-09-17 07:56:09
合計ジャッジ時間 10,260 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,112 KB
testcase_01 AC 74 ms
71,108 KB
testcase_02 AC 74 ms
71,268 KB
testcase_03 AC 542 ms
154,020 KB
testcase_04 AC 396 ms
128,916 KB
testcase_05 AC 325 ms
115,916 KB
testcase_06 AC 587 ms
162,120 KB
testcase_07 AC 171 ms
88,108 KB
testcase_08 AC 391 ms
125,404 KB
testcase_09 AC 220 ms
95,908 KB
testcase_10 AC 389 ms
125,876 KB
testcase_11 AC 489 ms
144,488 KB
testcase_12 AC 445 ms
136,656 KB
testcase_13 AC 661 ms
175,192 KB
testcase_14 AC 661 ms
175,300 KB
testcase_15 AC 666 ms
175,124 KB
testcase_16 AC 655 ms
175,044 KB
testcase_17 AC 658 ms
175,152 KB
testcase_18 AC 625 ms
175,176 KB
testcase_19 AC 563 ms
175,292 KB
testcase_20 AC 73 ms
71,364 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 j in range(7)] for i in range(K+1)]
dp[K][0][1] = 1
for i in reversed(range(K)):
    mem = pow(10,L[i],7)
    for j in range(7):
        for k in range(7):
            dp[i][j][k] += dp[i+1][j][k]
            dp[i][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
            dp[i][S][T] += dp[i+1][j][k]
            dp[i][S][T] %= mod
ans = 0
for i in range(7):
    for j in range(7):
        ans += dp[0][i][j]*i
        ans %= mod
print(ans)
0