結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー 👑 KazunKazun
提出日時 2021-08-05 20:34:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 308 ms / 3,000 ms
コード長 538 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 108,856 KB
最終ジャッジ日時 2023-10-14 21:40:24
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,304 KB
testcase_01 AC 71 ms
71,364 KB
testcase_02 AC 71 ms
71,444 KB
testcase_03 AC 92 ms
76,804 KB
testcase_04 AC 73 ms
71,360 KB
testcase_05 AC 71 ms
71,244 KB
testcase_06 AC 70 ms
71,368 KB
testcase_07 AC 71 ms
71,232 KB
testcase_08 AC 75 ms
75,804 KB
testcase_09 AC 78 ms
75,924 KB
testcase_10 AC 76 ms
76,236 KB
testcase_11 AC 78 ms
75,844 KB
testcase_12 AC 79 ms
75,768 KB
testcase_13 AC 77 ms
76,164 KB
testcase_14 AC 291 ms
107,392 KB
testcase_15 AC 298 ms
108,856 KB
testcase_16 AC 296 ms
108,628 KB
testcase_17 AC 302 ms
108,532 KB
testcase_18 AC 300 ms
108,712 KB
testcase_19 AC 308 ms
108,484 KB
testcase_20 AC 78 ms
76,120 KB
testcase_21 AC 88 ms
76,496 KB
testcase_22 AC 83 ms
76,700 KB
testcase_23 AC 94 ms
76,792 KB
testcase_24 AC 89 ms
76,464 KB
testcase_25 AC 85 ms
76,180 KB
testcase_26 AC 96 ms
78,020 KB
testcase_27 AC 180 ms
88,556 KB
testcase_28 AC 131 ms
83,300 KB
testcase_29 AC 96 ms
76,784 KB
testcase_30 AC 135 ms
84,456 KB
testcase_31 AC 147 ms
87,388 KB
権限があれば一括ダウンロードができます

ソースコード

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(k):
    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