結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー moharan627moharan627
提出日時 2021-07-30 21:12:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,213 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 77,492 KB
最終ジャッジ日時 2023-10-14 02:38:48
合計ジャッジ時間 2,837 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
76,924 KB
testcase_01 AC 82 ms
77,180 KB
testcase_02 AC 84 ms
76,940 KB
testcase_03 AC 81 ms
77,060 KB
testcase_04 AC 84 ms
77,200 KB
testcase_05 AC 84 ms
77,256 KB
testcase_06 AC 82 ms
77,348 KB
testcase_07 AC 84 ms
77,424 KB
testcase_08 AC 83 ms
77,188 KB
testcase_09 AC 82 ms
77,456 KB
testcase_10 AC 83 ms
77,180 KB
testcase_11 AC 83 ms
77,092 KB
testcase_12 AC 82 ms
77,312 KB
testcase_13 AC 83 ms
77,236 KB
testcase_14 AC 83 ms
77,304 KB
testcase_15 AC 82 ms
77,492 KB
testcase_16 AC 85 ms
77,144 KB
testcase_17 AC 84 ms
77,284 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 200100
    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