結果
問題 |
No.1629 Sorting Integers (SUM of M)
|
ユーザー |
|
提出日時 | 2021-07-30 21:12:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 1,213 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 59,904 KB |
最終ジャッジ日時 | 2024-09-15 22:17:36 |
合計ジャッジ時間 | 2,071 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 14 |
ソースコード
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)#再帰関数ではコメントにしないこと!!