結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー minimumminimum
提出日時 2021-07-30 21:14:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 711 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 815,504 KB
最終ジャッジ日時 2023-10-14 02:49:29
合計ジャッジ時間 8,014 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,948 KB
testcase_01 AC 16 ms
8,080 KB
testcase_02 AC 17 ms
7,940 KB
testcase_03 AC 1,233 ms
13,980 KB
testcase_04 AC 17 ms
7,948 KB
testcase_05 AC 16 ms
7,968 KB
testcase_06 AC 17 ms
7,944 KB
testcase_07 AC 18 ms
8,024 KB
testcase_08 AC 39 ms
8,476 KB
testcase_09 AC 1,207 ms
14,544 KB
testcase_10 AC 82 ms
8,476 KB
testcase_11 AC 395 ms
10,296 KB
testcase_12 AC 188 ms
9,468 KB
testcase_13 AC 40 ms
7,964 KB
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial

n, k = map(int, input().split())

c = list(map(int, input().split()))

d = []
for i in range(1, 10):
    for j in range(c[i - 1]):
        d.append(i)


dp = [[[0] * k for j in range(2 ** n)] for i in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    now = d[i]
    for j in range(2 ** n):
        for x in range(n):
            if (j >> x) & 1 == 0:
                y = now * pow(10, x, k)
                y %= k
                for l in range(k):
                    dp[i + 1][j + (2 ** x)][(l + y) % k] += dp[i][j][l]
        for l in range(k):
            dp[i + 1][j][l] += dp[i][j][l]

ans = dp[n][2 ** n - 1][0]

for i in range(9):
    ans //= factorial(c[i])

print(ans)
0