結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー 👑 KazunKazun
提出日時 2021-08-05 20:27:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 541 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 115,336 KB
最終ジャッジ日時 2023-10-14 21:40:18
合計ジャッジ時間 7,766 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,376 KB
testcase_01 RE -
testcase_02 AC 72 ms
71,552 KB
testcase_03 AC 95 ms
76,692 KB
testcase_04 AC 71 ms
71,136 KB
testcase_05 AC 70 ms
71,228 KB
testcase_06 RE -
testcase_07 AC 70 ms
71,132 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
N,K=map(int,input().split())
C=[0]+list(map(int,input().split()))

X=[]
for i in range(10):
    X+=[i]*C[i]

D={}
M=[]
k=0
for t in product(*[range(C[i]+1) for i in range(10)]):
    D[t]=k
    M.append(t)
    k+=1

DP=[[0]*K for _ in range(k)]
DP[0][0]=1

for S in range(1<<N):
    t=M[S]
    l=list(t)
    for r in range(10):
        if t[r]+1<=C[r]:
            l[r]+=1
            T=D[tuple(l)]
            for m in range(K):
                DP[T][(10*m+r)%K]+=DP[S][m]
            l[r]-=1

print(DP[-1][0])
0