結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー とりゐとりゐ
提出日時 2021-07-08 15:40:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,163 ms / 3,000 ms
コード長 536 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 206,276 KB
最終ジャッジ日時 2023-10-14 02:15:39
合計ジャッジ時間 34,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,052 KB
testcase_01 AC 74 ms
71,136 KB
testcase_02 AC 73 ms
71,184 KB
testcase_03 AC 99 ms
76,768 KB
testcase_04 AC 72 ms
71,396 KB
testcase_05 AC 72 ms
71,488 KB
testcase_06 AC 71 ms
71,468 KB
testcase_07 AC 75 ms
71,156 KB
testcase_08 AC 79 ms
75,880 KB
testcase_09 AC 86 ms
76,240 KB
testcase_10 AC 80 ms
76,464 KB
testcase_11 AC 81 ms
76,188 KB
testcase_12 AC 77 ms
75,860 KB
testcase_13 AC 84 ms
76,488 KB
testcase_14 AC 2,071 ms
200,336 KB
testcase_15 AC 2,145 ms
206,276 KB
testcase_16 AC 2,152 ms
206,152 KB
testcase_17 AC 2,161 ms
205,916 KB
testcase_18 AC 2,163 ms
206,220 KB
testcase_19 AC 2,144 ms
206,256 KB
testcase_20 AC 2,157 ms
206,148 KB
testcase_21 AC 1,924 ms
190,624 KB
testcase_22 AC 2,119 ms
203,880 KB
testcase_23 AC 2,123 ms
203,856 KB
testcase_24 AC 2,116 ms
203,960 KB
testcase_25 AC 2,114 ms
202,752 KB
testcase_26 AC 99 ms
78,488 KB
testcase_27 AC 1,602 ms
170,260 KB
testcase_28 AC 762 ms
117,256 KB
testcase_29 AC 772 ms
117,496 KB
testcase_30 AC 1,055 ms
136,300 KB
testcase_31 AC 1,598 ms
169,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,p=map(int,input().split())
c=list(map(int,input().split()))
a=[]
for i in range(9):
  for j in range(c[i]):
    a.append(i+1)
dp=[[0]*p for i in range(1<<n)]
dp[0][0]=1
q=[1]*n
for i in range(1,n):
  q[i]=(q[i-1]*10)%p
s=set([0])
for i in range(1<<n):
  j=bin(i).count("1")
  for k in range(n):
    if (i>>k)&1==0:
      for l in range(p):
        dp[i+2**k][(l+q[k]*a[j])%p]+=dp[i][l]
ans=dp[2**n-1][0]
fact=[1]*(n+1)
for i in range(1,n+1):
  fact[i]=fact[i-1]*i
c=[0]*9
for i in a:
  c[i-1]+=1
for i in c:
  ans//=fact[i]
print(ans)
0