結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー lloyzlloyz
提出日時 2021-12-27 23:40:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,322 ms / 3,000 ms
コード長 596 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 204,576 KB
最終ジャッジ日時 2024-04-08 18:56:10
合計ジャッジ時間 26,231 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 41 ms
53,460 KB
testcase_03 AC 56 ms
64,316 KB
testcase_04 AC 40 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 40 ms
53,460 KB
testcase_07 AC 44 ms
57,428 KB
testcase_08 AC 50 ms
59,516 KB
testcase_09 AC 55 ms
62,220 KB
testcase_10 AC 53 ms
62,240 KB
testcase_11 AC 51 ms
62,232 KB
testcase_12 AC 52 ms
62,236 KB
testcase_13 AC 52 ms
62,236 KB
testcase_14 AC 1,533 ms
198,644 KB
testcase_15 AC 2,311 ms
204,448 KB
testcase_16 AC 2,322 ms
204,448 KB
testcase_17 AC 2,307 ms
204,448 KB
testcase_18 AC 2,311 ms
204,448 KB
testcase_19 AC 2,317 ms
204,448 KB
testcase_20 AC 451 ms
204,576 KB
testcase_21 AC 553 ms
188,916 KB
testcase_22 AC 650 ms
202,228 KB
testcase_23 AC 1,295 ms
202,228 KB
testcase_24 AC 987 ms
202,228 KB
testcase_25 AC 854 ms
200,948 KB
testcase_26 AC 57 ms
64,304 KB
testcase_27 AC 1,682 ms
168,692 KB
testcase_28 AC 822 ms
115,188 KB
testcase_29 AC 761 ms
115,956 KB
testcase_30 AC 1,121 ms
134,388 KB
testcase_31 AC 1,671 ms
168,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, k = map(int, input().split())
C = list(map(int, input().split()))
L = []
for i in range(9):
    L += [i + 1] * C[i]

DP = [[0] * k for _ in range(1 << n)]
DP[0][0] = 1
for bit in range(1 << n):
    for i in range(k):
        if DP[bit][i] == 0:
            continue
        for j in range(n):
            if bit & (1 << j):
                continue
            r = (10 * i + L[j]) % k
            nbit = bit | (1 << j)
            DP[nbit][r] += DP[bit][i]
ans = DP[-1][0]
for i in range(9):
    for j in range(1, C[i] + 1):
        ans //= j
print(ans)
0