結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2021-07-30 23:34:00 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 627 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 87,100 KB |
実行使用メモリ | 200,528 KB |
最終ジャッジ日時 | 2023-10-14 08:37:37 |
合計ジャッジ時間 | 7,812 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
78,412 KB |
testcase_01 | AC | 72 ms
71,644 KB |
testcase_02 | AC | 73 ms
71,348 KB |
testcase_03 | AC | 93 ms
76,844 KB |
testcase_04 | AC | 73 ms
71,332 KB |
testcase_05 | AC | 78 ms
71,224 KB |
testcase_06 | AC | 75 ms
71,380 KB |
testcase_07 | AC | 78 ms
75,728 KB |
testcase_08 | AC | 79 ms
75,920 KB |
testcase_09 | AC | 88 ms
76,856 KB |
testcase_10 | AC | 87 ms
76,652 KB |
testcase_11 | AC | 85 ms
76,556 KB |
testcase_12 | AC | 83 ms
76,952 KB |
testcase_13 | AC | 85 ms
76,648 KB |
testcase_14 | AC | 1,411 ms
200,528 KB |
testcase_15 | TLE | - |
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 | -- | - |
ソースコード
n,k = map(int,input().split()) C = list(map(int,input().split())) l = [] for i,c in enumerate(C,1): for j in range(c): l.append(i) ten = [1] for i in range(n+1): ten.append(ten[-1]*10%k) dp = [[0]*k for i in range(1<<n)] dp[0][0] = 1 for i in range(1<<n): for j in range(k): if dp[i][j] == 0: continue b = bin(i).count("1") for t in range(n): if i >> t & 1: continue dp[i|1<<t][(j+ten[t]*l[b])%k] += dp[i][j] ans = dp[-1][0] fact = [1] for i in range(1,n+1): fact.append(fact[-1]*i) for c in C: ans //= fact[c] print(ans)