結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー 👑 rin204rin204
提出日時 2021-07-30 20:38:43
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 812 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 79,344 KB
最終ジャッジ日時 2023-10-14 02:52:50
合計ジャッジ時間 3,755 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
70,860 KB
testcase_01 AC 72 ms
71,212 KB
testcase_02 AC 74 ms
71,216 KB
testcase_03 AC 73 ms
71,172 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
N = 1000
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
    fact[i] = fact[i - 1] * i % MOD

invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)

for i in range(N - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD

def nCk(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fact[n] * invfact[k] % MOD) * invfact[n - k] % MOD

def nHk(n, k):
    return nCk(n + k - 1, k)


n = int(input())
cnt = list(map(int, input().split()))
m = n
times = 1
for c in cnt:
    times *= nCk(m, c)
    m -= c
    times %= MOD
    
tot = 0
for i, c in enumerate(cnt, 1):
    tot += i * (times * pow(nCk(n, c), MOD - 2, MOD) * nCk(n - 1, c - 1))
    tot %= MOD

print(tot * (pow(10, n, MOD) - 1) * pow(9, MOD - 2, MOD) % MOD)
    
    

0