結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-30 23:37:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,805 ms / 3,000 ms
コード長 623 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 206,456 KB
最終ジャッジ日時 2023-10-14 08:42:28
合計ジャッジ時間 22,402 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,120 KB
testcase_01 AC 75 ms
71,292 KB
testcase_02 AC 74 ms
71,184 KB
testcase_03 AC 92 ms
76,960 KB
testcase_04 AC 75 ms
71,164 KB
testcase_05 AC 74 ms
71,380 KB
testcase_06 AC 74 ms
71,416 KB
testcase_07 AC 74 ms
71,272 KB
testcase_08 AC 78 ms
76,000 KB
testcase_09 AC 85 ms
76,564 KB
testcase_10 AC 85 ms
76,096 KB
testcase_11 AC 85 ms
76,640 KB
testcase_12 AC 81 ms
76,092 KB
testcase_13 AC 86 ms
76,556 KB
testcase_14 AC 959 ms
200,620 KB
testcase_15 AC 1,564 ms
206,456 KB
testcase_16 AC 1,805 ms
206,388 KB
testcase_17 AC 1,567 ms
206,224 KB
testcase_18 AC 1,755 ms
206,212 KB
testcase_19 AC 1,591 ms
206,440 KB
testcase_20 AC 874 ms
206,428 KB
testcase_21 AC 790 ms
190,744 KB
testcase_22 AC 880 ms
204,212 KB
testcase_23 AC 1,242 ms
204,276 KB
testcase_24 AC 998 ms
204,320 KB
testcase_25 AC 723 ms
202,848 KB
testcase_26 AC 99 ms
78,624 KB
testcase_27 AC 1,034 ms
170,596 KB
testcase_28 AC 645 ms
116,844 KB
testcase_29 AC 507 ms
117,684 KB
testcase_30 AC 703 ms
136,028 KB
testcase_31 AC 1,288 ms
169,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
C = list(map(int,input().split()))
l = []
for i,c in enumerate(C,1):
    for j in range(c):
        l.append(i)

ten = [1]
for i in range(n+1):
    ten.append(ten[-1]*10%k)

dp = [[0]*k for i in range(1<<n)]
dp[0][0] = 1
for i in range(1<<n):
    b = bin(i).count("1")
    for t in range(n):
        if i >> t & 1:
            continue
        for j in range(k):
            if dp[i][j] == 0:
                continue
            dp[i|1<<t][(j+ten[t]*l[b])%k] += dp[i][j]
ans = dp[-1][0]
fact = [1]
for i in range(1,n+1):
    fact.append(fact[-1]*i)
for c in C:
    ans //= fact[c]
print(ans)
0