結果
問題 | No.1631 Sorting Integers (Multiple of K) Easy |
ユーザー | arahi10 |
提出日時 | 2021-07-30 22:12:34 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,606 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 87,152 KB |
実行使用メモリ | 483,168 KB |
最終ジャッジ日時 | 2023-10-14 05:08:25 |
合計ジャッジ時間 | 9,256 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 226 ms
88,140 KB |
testcase_01 | AC | 226 ms
83,620 KB |
testcase_02 | AC | 223 ms
83,804 KB |
testcase_03 | AC | 277 ms
86,772 KB |
testcase_04 | AC | 226 ms
83,672 KB |
testcase_05 | AC | 226 ms
83,764 KB |
testcase_06 | AC | 225 ms
83,588 KB |
testcase_07 | AC | 227 ms
83,536 KB |
testcase_08 | AC | 228 ms
83,680 KB |
testcase_09 | AC | 265 ms
85,368 KB |
testcase_10 | AC | 268 ms
85,088 KB |
testcase_11 | AC | 270 ms
86,420 KB |
testcase_12 | AC | 239 ms
84,816 KB |
testcase_13 | AC | 260 ms
85,128 KB |
testcase_14 | TLE | - |
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 | -- | - |
ソースコード
#!/usr/bin/python3.8 N,K=map(int,input().split()) C=list(map(int,input().split())) nums=[] from collections import defaultdict from fractions import Fraction as fraction factorial=[1] for i in range(1,15): factorial.append(factorial[-1]*i) f=1 for v in C: f*=factorial[v] for i in range(1,10): nums+=[i]*C[i-1] dp=[defaultdict(int) for i in range(2**N)] dp[0]=[(0,fraction(1,f))] #########bit library ######### def popcount(a): return bin(a).count('1') #Sの部分集合の列挙、降順 def subset(S): T=S while T: T=S&(T-1) yield T #N桁の二進数のうち丁度Kbitだけ立っている数の列挙 #昇順 def Kbits(N,K): if N<K:raise ValueError if K==0:return [0] v=(1<<K)-1;MAX=1<<N while v<MAX: yield v x = v & (-v) y = v + x v = (v & ~y) // x >> 1 | y #S&v = v を満たすvの列挙、昇順 def flags(S): while S: v=S&(-S) S^=v yield v def flag_inds(S): while S: v=S&(-S) S^=v yield v.bit_length()-1 #1つだけビットが立っていないものの列挙、降順 def childs(S): tmp=S while tmp: v=tmp&(-tmp) tmp^=v yield S^v,v.bit_length()-1 def post(S): assert S>0 v=S&(-S) return S^v,v.bit_length()-1 #########bit library end######### for S in range(1,2**N): for P,j in childs(S): num=nums[j] for k,v in dp[P]: dp[S][(10*k+num)%K]+=v dp[S]=list(dp[S].items()) f=0 for k,v in dp[-1]: if k==0: f=v break from math import floor print(floor(f))