結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-30 23:39:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,628 ms / 3,000 ms
コード長 558 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 206,448 KB
最終ジャッジ日時 2023-10-14 08:45:36
合計ジャッジ時間 21,612 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,292 KB
testcase_01 AC 63 ms
71,480 KB
testcase_02 AC 63 ms
71,292 KB
testcase_03 AC 82 ms
77,044 KB
testcase_04 AC 68 ms
71,332 KB
testcase_05 AC 63 ms
71,292 KB
testcase_06 AC 64 ms
71,456 KB
testcase_07 AC 65 ms
71,300 KB
testcase_08 AC 68 ms
75,808 KB
testcase_09 AC 72 ms
76,860 KB
testcase_10 AC 71 ms
76,636 KB
testcase_11 AC 72 ms
76,788 KB
testcase_12 AC 68 ms
76,372 KB
testcase_13 AC 73 ms
76,736 KB
testcase_14 AC 1,247 ms
200,772 KB
testcase_15 AC 1,567 ms
206,312 KB
testcase_16 AC 1,628 ms
206,448 KB
testcase_17 AC 1,614 ms
206,436 KB
testcase_18 AC 1,545 ms
206,344 KB
testcase_19 AC 1,584 ms
206,344 KB
testcase_20 AC 731 ms
206,348 KB
testcase_21 AC 756 ms
190,720 KB
testcase_22 AC 880 ms
204,268 KB
testcase_23 AC 1,115 ms
204,340 KB
testcase_24 AC 1,002 ms
204,268 KB
testcase_25 AC 930 ms
202,576 KB
testcase_26 AC 89 ms
78,604 KB
testcase_27 AC 1,140 ms
170,508 KB
testcase_28 AC 577 ms
117,240 KB
testcase_29 AC 569 ms
118,012 KB
testcase_30 AC 811 ms
136,264 KB
testcase_31 AC 1,212 ms
170,120 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)

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*10+l[t])%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