結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー rlangevinrlangevin
提出日時 2022-12-31 23:18:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 83,920 KB
最終ジャッジ日時 2023-08-17 22:12:56
合計ジャッジ時間 4,549 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
83,632 KB
testcase_01 AC 91 ms
83,512 KB
testcase_02 AC 88 ms
83,816 KB
testcase_03 AC 88 ms
83,772 KB
testcase_04 AC 92 ms
83,752 KB
testcase_05 AC 92 ms
83,700 KB
testcase_06 AC 93 ms
83,600 KB
testcase_07 AC 92 ms
83,808 KB
testcase_08 AC 89 ms
83,844 KB
testcase_09 AC 89 ms
83,920 KB
testcase_10 AC 90 ms
83,880 KB
testcase_11 AC 89 ms
83,888 KB
testcase_12 AC 90 ms
83,792 KB
testcase_13 AC 90 ms
83,604 KB
testcase_14 AC 91 ms
83,880 KB
testcase_15 AC 89 ms
83,856 KB
testcase_16 AC 92 ms
83,840 KB
testcase_17 AC 93 ms
83,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = list(map(int, input().split()))
mod = 10 ** 9 + 7

n = 505050
fact = [1] * (n + 1)
invfact = [1] * (n + 2)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod
invfact[-1] = 0
    
v = 1
for i in range(N-1):
    v = 10 * v + 1
    v %= mod
ans = 0
for i in range(9):
    cnt = fact[N - 1]
    for j in range(9):
        if j != i:
            cnt *= invfact[C[j]]
        else:
            cnt *= invfact[C[j] - 1]
    cnt %= mod
    # print(i, cnt)  
    ans += v * (i + 1) * cnt
    ans %= mod
print(ans)    
0