結果

問題 No.2235 Line Up Colored Balls
ユーザー ShirotsumeShirotsume
提出日時 2023-03-03 22:00:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 89,340 KB
最終ジャッジ日時 2023-10-18 04:27:08
合計ジャッジ時間 11,025 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,448 KB
testcase_01 AC 43 ms
55,448 KB
testcase_02 AC 42 ms
55,448 KB
testcase_03 AC 44 ms
55,448 KB
testcase_04 AC 224 ms
89,340 KB
testcase_05 AC 44 ms
55,448 KB
testcase_06 AC 43 ms
55,448 KB
testcase_07 AC 203 ms
83,092 KB
testcase_08 AC 43 ms
55,448 KB
testcase_09 AC 43 ms
55,448 KB
testcase_10 AC 42 ms
55,448 KB
testcase_11 AC 44 ms
55,448 KB
testcase_12 AC 43 ms
55,448 KB
testcase_13 AC 43 ms
55,448 KB
testcase_14 AC 43 ms
55,448 KB
testcase_15 AC 42 ms
55,448 KB
testcase_16 AC 42 ms
55,448 KB
testcase_17 AC 44 ms
55,448 KB
testcase_18 AC 225 ms
89,132 KB
testcase_19 AC 227 ms
89,132 KB
testcase_20 AC 223 ms
89,132 KB
testcase_21 AC 225 ms
89,132 KB
testcase_22 AC 225 ms
89,132 KB
testcase_23 AC 224 ms
89,132 KB
testcase_24 AC 225 ms
89,132 KB
testcase_25 AC 224 ms
89,132 KB
testcase_26 AC 227 ms
89,132 KB
testcase_27 AC 224 ms
89,132 KB
testcase_28 AC 224 ms
88,292 KB
testcase_29 AC 225 ms
88,300 KB
testcase_30 AC 223 ms
88,296 KB
testcase_31 AC 225 ms
88,296 KB
testcase_32 AC 221 ms
88,236 KB
testcase_33 AC 223 ms
88,224 KB
testcase_34 AC 225 ms
88,268 KB
testcase_35 AC 224 ms
88,296 KB
testcase_36 AC 225 ms
88,272 KB
testcase_37 AC 224 ms
88,296 KB
testcase_38 AC 70 ms
68,364 KB
testcase_39 AC 58 ms
66,316 KB
testcase_40 AC 70 ms
70,412 KB
testcase_41 AC 163 ms
83,156 KB
testcase_42 AC 181 ms
85,460 KB
testcase_43 AC 61 ms
66,316 KB
testcase_44 AC 124 ms
79,612 KB
testcase_45 AC 64 ms
68,364 KB
testcase_46 AC 206 ms
87,204 KB
testcase_47 AC 126 ms
79,616 KB
testcase_48 AC 225 ms
89,132 KB
testcase_49 AC 224 ms
89,132 KB
testcase_50 AC 225 ms
89,132 KB
testcase_51 AC 225 ms
89,132 KB
testcase_52 AC 227 ms
89,132 KB
testcase_53 AC 224 ms
89,132 KB
testcase_54 AC 224 ms
89,132 KB
testcase_55 AC 225 ms
89,132 KB
testcase_56 AC 226 ms
89,132 KB
testcase_57 AC 226 ms
89,132 KB
testcase_58 AC 42 ms
55,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 10 ** 9 + 7
class Combinatorics():
    def __init__(self, mod, maxi):
        self.mod = mod
        self.maxi = maxi
        self.facs = [1] * (maxi + 1)
        self.factinvs = [1] * (maxi + 1)
        self.invs = [1] * (maxi + 1)
        for i in range(2, self.maxi + 1):
            self.facs[i] = ((self.facs[i-1] * i) % self.mod)
            self.invs[i] = (-self.invs[self.mod % i] * (self.mod // i)) % self.mod
            self.factinvs[i] = (self.factinvs[i-1] * self.invs[i]) % self.mod
            
    def choose(self, n, k) -> int:
        if k < 0 or k > n: return 0
        if k == 0 or k == n: return 1
        k = min(k, n - k)
        return (((self.facs[n] * self.factinvs[k]) % self.mod) * self.factinvs[n-k]) % self.mod
    
    def perm(self, n, k) -> int:
        return (self.choose(n, k) * self.facs[k]) % self.mod

    def homop(self, n, k) -> int:
        if n == k == 0:
            return 1
        return self.choose(n + k - 1, k)

n = ii()
a = li()
e = 0
s = sum(a)
for i in range(n):
    e += ((a[i] * pow(s, mod - 2, mod) % mod) * ((a[i] - 1) * pow(s - 1, mod - 2, mod) % mod)) * (s - 1)
    e %= mod
p = (s - 1 - e) % mod
print((p + 1) % mod)
0