結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー PSL24251284PSL24251284
提出日時 2021-07-31 03:35:35
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 471 bytes
コンパイル時間 1,676 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 206,372 KB
最終ジャッジ日時 2023-10-14 12:34:00
合計ジャッジ時間 56,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,188 KB
testcase_01 AC 77 ms
71,056 KB
testcase_02 AC 76 ms
71,100 KB
testcase_03 AC 138 ms
76,528 KB
testcase_04 AC 75 ms
71,072 KB
testcase_05 AC 75 ms
71,076 KB
testcase_06 AC 75 ms
70,952 KB
testcase_07 AC 78 ms
71,096 KB
testcase_08 AC 92 ms
76,328 KB
testcase_09 AC 103 ms
76,480 KB
testcase_10 AC 83 ms
76,264 KB
testcase_11 AC 91 ms
76,360 KB
testcase_12 AC 86 ms
76,324 KB
testcase_13 AC 83 ms
76,260 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 TLE -
testcase_26 AC 100 ms
78,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = bin(bit).count("1") - 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