結果

問題 No.2017 Mod7 Parade
ユーザー ntudantuda
提出日時 2022-08-11 15:25:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,776 KB
実行使用メモリ 53,460 KB
最終ジャッジ日時 2023-10-21 20:36:40
合計ジャッジ時間 4,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 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 #

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][j] += dp1[i][j]
    dp1 = dp2

ans = 0
X = [[0] * 7 for _ in range(6)]
for i in range(6):
    for j in range(7):
        ans += dp1[i][j] * j

print(ans)
0