結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー googol_S0googol_S0
提出日時 2021-07-30 20:34:16
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 83,036 KB
最終ジャッジ日時 2023-10-14 02:48:13
合計ジャッジ時間 2,981 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
82,672 KB
testcase_01 AC 89 ms
82,740 KB
testcase_02 AC 90 ms
83,036 KB
testcase_03 AC 93 ms
83,032 KB
testcase_04 AC 90 ms
82,936 KB
testcase_05 AC 91 ms
83,016 KB
testcase_06 AC 87 ms
82,856 KB
testcase_07 AC 89 ms
82,624 KB
testcase_08 AC 90 ms
82,812 KB
testcase_09 AC 90 ms
82,916 KB
testcase_10 AC 91 ms
82,624 KB
testcase_11 AC 89 ms
82,808 KB
testcase_12 AC 90 ms
82,808 KB
testcase_13 AC 90 ms
82,672 KB
testcase_14 AC 90 ms
82,808 KB
testcase_15 AC 91 ms
82,700 KB
testcase_16 AC 91 ms
82,932 KB
testcase_17 AC 90 ms
82,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
def cmb(n,r):
  if r<0 or r>n:
    return 0
  return (g1[n]*g2[r]*g2[n-r])%mod
 
N=300000
g1=[1]*(N+3)
for i in range(2,N+3):
  g1[i]=g1[i-1]*i%mod
g2=[0]*len(g1)
g2[-1]=pow(g1[-1],mod-2,mod)
for i in range(N+1,-1,-1):
  g2[i]=g2[i+1]*(i+1)%mod
inv=[0]*(N+3)
for i in range(1,N+3):
  inv[i]=g2[i]*g1[i-1]%mod

N=int(input())
ANS=0
C=list(map(int,input().split()))
for i in range(9):
  if C[i]==0:
    continue
  S=sum(C)-1
  x=i+1
  C[i]-=1
  for j in range(9):
    x=x*cmb(S,C[j])%mod
    S-=C[j]
  C[i]+=1
  ANS+=(pow(10,N,mod)-1)*pow(9,mod-2,mod)*x%mod
print(ANS%mod)
0