結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー minimumminimum
提出日時 2021-07-30 21:13:18
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 710 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 840,384 KB
最終ジャッジ日時 2023-10-14 02:43:21
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,300 KB
testcase_01 AC 70 ms
71,084 KB
testcase_02 AC 73 ms
71,336 KB
testcase_03 AC 185 ms
82,824 KB
testcase_04 AC 71 ms
71,280 KB
testcase_05 AC 73 ms
70,840 KB
testcase_06 AC 72 ms
70,864 KB
testcase_07 AC 76 ms
75,596 KB
testcase_08 AC 83 ms
75,932 KB
testcase_09 AC 161 ms
83,132 KB
testcase_10 AC 100 ms
76,560 KB
testcase_11 AC 125 ms
79,452 KB
testcase_12 AC 101 ms
76,512 KB
testcase_13 AC 106 ms
77,544 KB
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import factorial

n, k = map(int, input().split())

c = list(map(int, input().split()))

d = []
for i in range(1, 10):
    for j in range(c[i - 1]):
        d.append(i)


dp = [[[0] * k for j in range(2 ** n)] for i in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    now = d[i]
    for j in range(2 ** n):
        for x in range(n):
            if (j >> x) & 1 == 0:
                y = now * pow(10, x, k)
                y %= k
                for l in range(k):
                    dp[i + 1][j + (2 ** x)][(l + y) % k] += dp[i][j][l]
        for l in range(k):
            dp[i + 1][j][l] += dp[i][j][l]

ans = dp[n][2 ** n - 1][0]

for i in range(9):
    ans //= factorial(c[i])

print(ans)
0