結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー ああいいああいい
提出日時 2022-03-02 10:42:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,279 ms / 3,000 ms
コード長 535 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 206,064 KB
最終ジャッジ日時 2023-09-23 04:56:41
合計ジャッジ時間 21,981 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,480 KB
testcase_01 AC 74 ms
71,308 KB
testcase_02 AC 74 ms
71,168 KB
testcase_03 AC 85 ms
76,316 KB
testcase_04 AC 73 ms
71,236 KB
testcase_05 AC 75 ms
71,216 KB
testcase_06 AC 74 ms
71,060 KB
testcase_07 AC 74 ms
70,980 KB
testcase_08 AC 75 ms
75,824 KB
testcase_09 AC 83 ms
75,928 KB
testcase_10 AC 79 ms
76,124 KB
testcase_11 AC 82 ms
76,244 KB
testcase_12 AC 78 ms
75,980 KB
testcase_13 AC 79 ms
76,040 KB
testcase_14 AC 1,224 ms
200,284 KB
testcase_15 AC 1,277 ms
205,696 KB
testcase_16 AC 1,279 ms
205,928 KB
testcase_17 AC 1,275 ms
206,048 KB
testcase_18 AC 1,277 ms
206,064 KB
testcase_19 AC 1,273 ms
205,896 KB
testcase_20 AC 1,273 ms
205,696 KB
testcase_21 AC 1,123 ms
182,944 KB
testcase_22 AC 1,251 ms
203,392 KB
testcase_23 AC 1,255 ms
203,736 KB
testcase_24 AC 1,253 ms
203,784 KB
testcase_25 AC 1,243 ms
202,268 KB
testcase_26 AC 85 ms
76,484 KB
testcase_27 AC 935 ms
160,372 KB
testcase_28 AC 451 ms
113,908 KB
testcase_29 AC 458 ms
114,100 KB
testcase_30 AC 630 ms
135,452 KB
testcase_31 AC 937 ms
160,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
c = list(map(int,input().split()))
l = []
for i in range(9):
    for _ in range(c[i]):
        l.append(i+1)
dp = [[0] * K for _ in range(1 << N)]
dp[0][0] = 1
for bit in range(1,1 << N):
    for i in range(N):
        mask = 1 << i
        if mask & bit == 0:
            continue
        for j in range(K):
            dp[bit][(j*10+l[i])%K] += dp[bit ^ mask][j]
ans = dp[-1][0]
fact = [1] * (N+1)
for i in range(2,N+1):
    fact[i] = fact[i-1] * i
for i in range(9):
    ans //= fact[c[i]]
print(ans)
0