結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー moharan627moharan627
提出日時 2021-07-30 21:11:16
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,213 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,480 KB
実行使用メモリ 79,316 KB
最終ジャッジ日時 2023-10-14 02:35:12
合計ジャッジ時間 2,980 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
76,684 KB
testcase_01 AC 77 ms
76,776 KB
testcase_02 AC 79 ms
76,636 KB
testcase_03 AC 85 ms
76,992 KB
testcase_04 AC 79 ms
76,880 KB
testcase_05 AC 80 ms
76,808 KB
testcase_06 AC 80 ms
76,876 KB
testcase_07 AC 81 ms
77,120 KB
testcase_08 AC 80 ms
77,124 KB
testcase_09 AC 81 ms
77,040 KB
testcase_10 AC 84 ms
76,872 KB
testcase_11 AC 82 ms
77,036 KB
testcase_12 AC 82 ms
76,824 KB
testcase_13 AC 80 ms
77,104 KB
testcase_14 AC 80 ms
76,880 KB
testcase_15 AC 81 ms
77,048 KB
testcase_16 AC 81 ms
77,108 KB
testcase_17 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N = II()
    C = LI()
    Ans = 0
    Base = 1
    for n in range(N-1):
        Base = 10*Base + 1
        Base %= MOD
    #print(Base)
    def modinv(x):
        return pow(x, MOD - 2, MOD)
    MAX = 200000
    Fact = [0] * MAX
    Fact[0] = 1
    Fact[1] = 1
    for n in range(2, MAX):
        Fact[n] = (n * (Fact[n - 1])) % MOD
    #print((Fact[N + K] * modinv(Fact[N] * Fact[K])) % MOD)
    CSUM = sum(C)
    All = Fact[N]
    for c in range(9):
        All *= modinv(Fact[C[c]])
        All %= MOD
    #print(All)
    #print(All//N)
    for c in range(9):
        k = C[c]
        #print((All//N)*C[c]*(c+1)*Base)
        Ans += (All*modinv(N))*C[c]*(c+1)*Base
        Ans %= MOD
    print(Ans % MOD)
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0