結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー sotanishysotanishy
提出日時 2021-07-30 21:00:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 2,579 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 81,300 KB
最終ジャッジ日時 2023-10-14 01:38:06
合計ジャッジ時間 4,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,016 KB
testcase_01 AC 72 ms
71,228 KB
testcase_02 AC 72 ms
71,156 KB
testcase_03 AC 73 ms
71,088 KB
testcase_04 AC 157 ms
79,732 KB
testcase_05 AC 101 ms
77,620 KB
testcase_06 AC 108 ms
77,936 KB
testcase_07 AC 213 ms
81,300 KB
testcase_08 AC 171 ms
80,052 KB
testcase_09 AC 202 ms
80,800 KB
testcase_10 AC 177 ms
80,388 KB
testcase_11 AC 150 ms
79,084 KB
testcase_12 AC 217 ms
79,988 KB
testcase_13 AC 229 ms
80,828 KB
testcase_14 AC 181 ms
79,228 KB
testcase_15 AC 233 ms
81,016 KB
testcase_16 AC 232 ms
80,832 KB
testcase_17 AC 360 ms
81,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline


def comb_preprocess(n, mod):
    fact = [1] * (n+1)
    fact_inv = [1] * (n+1)
    for i in range(1, n+1):
        fact[i] = i * fact[i-1] % mod
    fact_inv[n] = pow(fact[n], mod-2, mod)
    for i in range(1, n+1)[::-1]:
        fact_inv[i-1] = i * fact_inv[i] % mod

    def comb(n, k):
        if k < 0 or n < k:
            return 0
        return fact[n] * fact_inv[k] * fact_inv[n-k] % mod

    return fact, fact_inv, comb

mod = 10**9 + 7
N = int(input())
c = [0] + list(map(int, input().split()))
fact, fact_inv, comb = comb_preprocess(N, mod)
den = 1
for d in range(1, 10):
    den = den * fact_inv[c[d]] % mod
ans = 0
pow10 = [1] * N
for i in range(1, N):
    pow10[i] = 10 * pow10[i-1] % mod
for i in range(N):
    for d in range(1, 10):
        ans += d * pow10[i] * fact[N-1] * den * c[d]
        ans %= mod
print(ans)


0