結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー lloyzlloyz
提出日時 2021-12-27 23:13:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 723 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 204,688 KB
最終ジャッジ日時 2024-04-08 18:05:46
合計ジャッジ時間 39,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 64 ms
68,472 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 41 ms
59,384 KB
testcase_08 AC 42 ms
59,380 KB
testcase_09 AC 53 ms
64,300 KB
testcase_10 AC 50 ms
62,244 KB
testcase_11 AC 51 ms
64,316 KB
testcase_12 AC 49 ms
62,236 KB
testcase_13 AC 51 ms
64,316 KB
testcase_14 AC 2,367 ms
198,800 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 591 ms
204,688 KB
testcase_21 AC 687 ms
189,200 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1,322 ms
202,384 KB
testcase_25 WA -
testcase_26 AC 80 ms
77,060 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
C = list(map(int, input().split()))
L = []
for i in range(9):
    for num in range(C[i]):
        L.append(i + 1)

DP = [[0 for _ in range(k)] for _ in range(1 << n)]
DP[0][0] = 1
for bit in range(1 << n):
    seen = set()
    digit = 0
    for i in range(n):
        if (bit >> i) & 1:
            seen.add(i)
            digit += 1
    for i in range(k):
        if DP[bit][i] != 0:
            for j in range(n):
                if j in seen:
                    continue
                num = pow(10, digit) * L[j]
                r = (i + num) % k
                DP[bit | (1 << j)][r] += DP[bit][i]
ans = DP[-1][0]
for i in range(9):
    if C[i] != 0:
        ans //= C[i]
print(ans)
0