結果

問題 No.766 金魚すくい
ユーザー neterukunneterukun
提出日時 2019-06-05 23:12:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,382 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 81,668 KB
実行使用メモリ 107,992 KB
最終ジャッジ日時 2023-10-23 18:42:54
合計ジャッジ時間 8,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,420 KB
testcase_01 WA -
testcase_02 AC 39 ms
53,420 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 55 ms
64,444 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 246 ms
107,332 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 175 ms
99,160 KB
testcase_34 AC 176 ms
99,172 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 247 ms
107,356 KB
testcase_38 AC 256 ms
107,332 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 38 ms
53,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#Combinationクラス
class Combination:

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i] ,MOD - 2 ,MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        '''k!を求める'''
        return self.fact[k]

    def inverse_factorial(self, k):
        '''k!の逆元を求める'''
        return self.inv_fact[k]

    def combination(self, k, r):
        '''kCrを求める'''
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, m, p = map(int, input().split())
v = list(map(int, input().split()))
MOD = 10**9 + 7
comb = Combination(n+m, MOD)

v = sorted(v, reverse = True)
point = [0]*(n+1)
for i in range(n):
    point[i+1] = point[i] + v[i]

ans = 0
ruiseki_p = 0
miss = (p * pow(100 ,MOD-2, MOD)) % MOD
miss = pow(miss, m, MOD)
tmp_success = (1 - miss) % MOD
success = pow((1 - miss) % MOD, MOD-2, MOD)
#0~n-1匹の金魚をすくう場合
for i in range(n):
    success *= tmp_success
    success %= MOD
    ans += miss * success * comb.combination(m-1+i, i) * point[i]
    ans %= MOD
    ruiseki_p += miss * success * comb.combination(m-1+i, i)
    ruiseki_p %= MOD

#n匹の金魚をすくう場合
if n != 1:
    ans += (1 - ruiseki_p) * point[n]

print(ans % MOD)
    
0