結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー PSL24251284PSL24251284
提出日時 2021-07-31 03:30:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 515 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 208,404 KB
最終ジャッジ日時 2023-10-14 12:25:05
合計ジャッジ時間 11,694 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,828 KB
testcase_01 AC 74 ms
71,128 KB
testcase_02 AC 74 ms
70,996 KB
testcase_03 AC 98 ms
76,052 KB
testcase_04 AC 73 ms
70,760 KB
testcase_05 AC 74 ms
71,008 KB
testcase_06 AC 73 ms
71,016 KB
testcase_07 AC 75 ms
71,020 KB
testcase_08 AC 85 ms
75,992 KB
testcase_09 AC 96 ms
76,356 KB
testcase_10 AC 82 ms
76,164 KB
testcase_11 AC 87 ms
76,328 KB
testcase_12 AC 84 ms
76,332 KB
testcase_13 AC 82 ms
76,224 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
c = [0] + list(map(int,input().split()))
S = []
for i in range(10):
    for j in range(c[i]):
        S.append(i)

dp = [[0]*K for i in range(1<<N)]
dp[0][0] = 1
for bit in range(1,1<<N):
    n = -1
    for i in range(N):
        if (bit>>i)&1:
            n += 1
    for k in range(K):
        for i in range(N):
            if (bit>>i)&1:
                dp[bit][k] += dp[bit^(1<<i)][(k-S[n]*10**i)%K]
ans = dp[-1][0]
for i in range(10):
    if c[i]:
        ans //= c[i]
print(ans)
0