結果

問題 No.2017 Mod7 Parade
ユーザー ああいいああいい
提出日時 2022-07-24 15:00:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 341 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 84,692 KB
最終ジャッジ日時 2023-09-20 14:17:38
合計ジャッジ時間 6,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,180 KB
testcase_01 AC 77 ms
71,608 KB
testcase_02 AC 77 ms
71,464 KB
testcase_03 AC 296 ms
83,272 KB
testcase_04 AC 230 ms
81,860 KB
testcase_05 AC 203 ms
81,428 KB
testcase_06 AC 305 ms
83,204 KB
testcase_07 AC 141 ms
77,984 KB
testcase_08 AC 226 ms
82,032 KB
testcase_09 AC 158 ms
78,672 KB
testcase_10 AC 228 ms
81,976 KB
testcase_11 AC 268 ms
82,752 KB
testcase_12 AC 248 ms
81,964 KB
testcase_13 AC 340 ms
83,132 KB
testcase_14 AC 332 ms
83,280 KB
testcase_15 AC 341 ms
83,388 KB
testcase_16 AC 333 ms
83,552 KB
testcase_17 AC 334 ms
83,184 KB
testcase_18 AC 337 ms
83,372 KB
testcase_19 AC 333 ms
84,692 KB
testcase_20 AC 79 ms
71,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())
D = []
L = []
for _ in range(K):
    d,l = map(int,input().split())
    D.append(d)
    L.append(l)
P = 10 ** 9 + 7
inv = pow(9,5,7)
beki = [pow(10,i,7) for i in range(6)]
dp = [[0] * 7 for _ in range(6)]
dp[0][0] = 1
ans = 0

for i in range(K - 1,-1,-1):
    d,l = D[i],L[i]
    nx = [[0] * 7 for _ in range(6)]
    
    for j in range(6):
        for k in range(7):
            u = (j + l) % 6
            tmp = beki[u] - beki[j]
            tmp = (tmp * inv * d + k) % 7
            ans += tmp * dp[j][k] % P
            ans %= P
            nx[j][k] += dp[j][k]
            nx[(j + l) % 6][tmp] += dp[j][k]
    for j in range(6):
        for k in range(7):
            nx[j][k] %= P
    #print(ans)
    dp = nx
print(ans)
t = 0
for i in range(6):
    for j in range(7):
        t += dp[i][j]
#print(t)
        
0