結果
| 問題 |
No.1629 Sorting Integers (SUM of M)
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:15:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 825 bytes |
| コンパイル時間 | 139 ms |
| コンパイル使用メモリ | 82,508 KB |
| 実行使用メモリ | 62,964 KB |
| 最終ジャッジ日時 | 2025-03-20 21:16:17 |
| 合計ジャッジ時間 | 1,609 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 |
ソースコード
MOD = 10**9 + 7
max_n = 200000
# Precompute factorial and inverse factorial modulo MOD
fact = [1] * (max_n + 1)
for i in range(1, max_n + 1):
fact[i] = fact[i-1] * i % MOD
inv_fact = [1] * (max_n + 1)
inv_fact[max_n] = pow(fact[max_n], MOD-2, MOD)
for i in range(max_n - 1, -1, -1):
inv_fact[i] = inv_fact[i + 1] * (i + 1) % MOD
inv_9 = pow(9, MOD - 2, MOD)
n = int(input())
c = list(map(int, input().split()))
sum_d = 0
for i in range(9):
sum_d += (i + 1) * c[i]
sum_d %= MOD
product_t = 1
for i in range(9):
cnt = c[i]
product_t = product_t * inv_fact[cnt] % MOD
T = fact[n] * product_t % MOD
inv_n = pow(n, MOD - 2, MOD)
pow_10_n = pow(10, n, MOD)
sum_10_terms = (pow_10_n - 1) * inv_9 % MOD
total = sum_d * T % MOD
total = total * inv_n % MOD
total = total * sum_10_terms % MOD
print(total)
lam6er