結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー |
👑 ![]() |
提出日時 | 2021-07-30 22:04:39 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 82,076 KB |
実行使用メモリ | 488,448 KB |
最終ジャッジ日時 | 2024-09-16 00:18:17 |
合計ジャッジ時間 | 5,685 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 TLE * 1 -- * 17 |
ソースコード
""""""import sysfrom sys import stdinimport mathN,K = map(int,stdin.readline().split())mod = Kc = [0] + list(map(int,stdin.readline().split()))C = []for i in range(10):for j in range(c[i]):C.append(i)dp = [ {} for i in range(2**N) ]dic = dpdp[0][0] = 1for i in range(2**N):popcnt = 0for j in range(N):if 2**j & i > 0:popcnt += 1npow = pow(10,popcnt,mod)for j in range(N):if i & (2**j) == 0:nexv = i | (2**j)for nm in dic[i]:nexm = (nm + C[j] * npow) % modif nexm not in dp[nexv]:dp[nexv][nexm] = 0dp[nexv][nexm] += dp[i][nm]if 0 not in dp[2**N-1]:ans = 0else:ans = dp[2**N-1][0]for j in range(10):ans //= math.factorial(c[j])print (ans)