結果
問題 | No.1629 Sorting Integers (SUM of M) |
ユーザー |
![]() |
提出日時 | 2025-03-20 18:54:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 825 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 63,624 KB |
最終ジャッジ日時 | 2025-03-20 18:56:53 |
合計ジャッジ時間 | 2,003 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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)