結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー brthyyjpbrthyyjp
提出日時 2021-08-01 19:20:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 93,732 KB
最終ジャッジ日時 2023-10-14 19:00:11
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
92,096 KB
testcase_01 AC 95 ms
92,044 KB
testcase_02 AC 100 ms
91,968 KB
testcase_03 AC 96 ms
92,256 KB
testcase_04 AC 98 ms
92,836 KB
testcase_05 AC 98 ms
92,452 KB
testcase_06 AC 98 ms
92,332 KB
testcase_07 AC 101 ms
93,212 KB
testcase_08 AC 98 ms
92,968 KB
testcase_09 AC 99 ms
93,164 KB
testcase_10 AC 99 ms
92,788 KB
testcase_11 AC 99 ms
92,752 KB
testcase_12 AC 101 ms
92,996 KB
testcase_13 AC 99 ms
93,096 KB
testcase_14 AC 100 ms
92,824 KB
testcase_15 AC 99 ms
93,004 KB
testcase_16 AC 99 ms
92,952 KB
testcase_17 AC 99 ms
93,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 10**6
mod = 10**9+7
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

n = int(input())
C = list(map(int, input().split()))
table = [0]*n
table[0] = 1
for i in range(1, n):
    table[i] = table[i-1]*10
    table[i] %= mod
s = sum(table)%mod
c = 0
for i in range(9):
    c += (i+1)*C[i]
c %= mod
ans = fac[n-1]*s*c
ans %= mod
for i in range(9):
    ans *= finv[C[i]]
print(ans%mod)
0