結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-07-30 22:04:39
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 860 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 512,688 KB
最終ジャッジ日時 2023-10-14 04:53:34
合計ジャッジ時間 6,276 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,256 KB
testcase_01 AC 71 ms
71,544 KB
testcase_02 AC 71 ms
71,236 KB
testcase_03 AC 96 ms
76,636 KB
testcase_04 AC 71 ms
71,368 KB
testcase_05 AC 74 ms
71,276 KB
testcase_06 AC 73 ms
71,196 KB
testcase_07 AC 72 ms
71,352 KB
testcase_08 AC 72 ms
71,440 KB
testcase_09 AC 83 ms
76,408 KB
testcase_10 AC 82 ms
76,476 KB
testcase_11 AC 83 ms
76,276 KB
testcase_12 AC 77 ms
76,248 KB
testcase_13 AC 84 ms
76,408 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 #

"""

"""

import sys
from sys import stdin
import math

N,K = map(int,stdin.readline().split())
mod = K

c = [0] + list(map(int,stdin.readline().split()))

C = []
for i in range(10):
    for j in range(c[i]):
        C.append(i)

dp = [ {} for i in range(2**N) ]
dic = dp
dp[0][0] = 1

for i in range(2**N):

    popcnt = 0
    for j in range(N):
        if 2**j & i > 0:
            popcnt += 1

    npow = pow(10,popcnt,mod)

    for j in range(N):

        if i & (2**j) == 0:
            
            nexv = i | (2**j)
            for nm in dic[i]:
                nexm = (nm + C[j] * npow) % mod

                if nexm not in dp[nexv]:
                    dp[nexv][nexm] = 0
                dp[nexv][nexm] += dp[i][nm]

if 0 not in dp[2**N-1]:
    ans = 0
else:
    ans = dp[2**N-1][0]

for j in range(10):
    ans //= math.factorial(c[j])

print (ans)
0