結果
問題 | No.1629 Sorting Integers (SUM of M) |
ユーザー |
![]() |
提出日時 | 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 + 7max_n = 200000# Precompute factorial and inverse factorial modulo MODfact = [1] * (max_n + 1)for i in range(1, max_n + 1):fact[i] = fact[i-1] * i % MODinv_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) % MODinv_9 = pow(9, MOD - 2, MOD)n = int(input())c = list(map(int, input().split()))sum_d = 0for i in range(9):sum_d += (i + 1) * c[i]sum_d %= MODproduct_t = 1for i in range(9):cnt = c[i]product_t = product_t * inv_fact[cnt] % MODT = fact[n] * product_t % MODinv_n = pow(n, MOD - 2, MOD)pow_10_n = pow(10, n, MOD)sum_10_terms = (pow_10_n - 1) * inv_9 % MODtotal = sum_d * T % MODtotal = total * inv_n % MODtotal = total * sum_10_terms % MODprint(total)