結果

問題 No.2017 Mod7 Parade
ユーザー ntudantuda
提出日時 2022-08-11 15:43:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,728 KB
実行使用メモリ 86,576 KB
最終ジャッジ日時 2023-10-21 20:48:19
合計ジャッジ時間 5,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,468 KB
testcase_01 AC 38 ms
53,468 KB
testcase_02 AC 38 ms
53,468 KB
testcase_03 AC 265 ms
84,564 KB
testcase_04 AC 195 ms
81,636 KB
testcase_05 AC 163 ms
80,224 KB
testcase_06 AC 271 ms
85,180 KB
testcase_07 AC 101 ms
77,336 KB
testcase_08 AC 184 ms
81,316 KB
testcase_09 AC 119 ms
78,160 KB
testcase_10 AC 186 ms
81,368 KB
testcase_11 AC 238 ms
83,328 KB
testcase_12 AC 218 ms
82,592 KB
testcase_13 AC 309 ms
86,568 KB
testcase_14 AC 319 ms
86,576 KB
testcase_15 AC 312 ms
86,564 KB
testcase_16 AC 298 ms
86,564 KB
testcase_17 AC 304 ms
86,568 KB
testcase_18 AC 291 ms
86,560 KB
testcase_19 AC 281 ms
86,564 KB
testcase_20 AC 36 ms
53,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
K = int(input())
DL = [list(map(int, input().split())) for _ in range(K)]

A = [5, 1, 3, 2, 6, 4]  # 桁が上がるときにかける数
B = [0, 1, 4, 6, 5, 2]  # xxxxの個数を計算する時にかける数

dp1 = [[0] * 7 for _ in range(6)]
# dp[i][j]:= 桁数i%6、数%7 の個数
dp1[0][0] = 1

for d, l in reversed(DL):
    dp2 = [[0] * 7 for _ in range(6)]
    add = (d * B[l % 6]) % 7
    for i in range(6):
        for j in range(7):
            dp2[(i + l) % 6][(j + add * A[(i + 1) % 6]) % 7] += dp1[i][j]
            dp2[(i + l) % 6][(j + add * A[(i + 1) % 6]) % 7] %= MOD
            dp2[i][j] += dp1[i][j]
            dp2[i][j] %= MOD
    dp1 = dp2

ans = 0
for i in range(6):
    for j in range(7):
        ans += dp1[i][j] * j
        ans %= MOD
print(ans)
0