結果

問題 No.766 金魚すくい
ユーザー neterukunneterukun
提出日時 2019-06-05 23:06:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,367 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,060 KB
実行使用メモリ 36,016 KB
最終ジャッジ日時 2023-10-23 18:33:09
合計ジャッジ時間 22,068 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,224 KB
testcase_01 AC 30 ms
10,228 KB
testcase_02 AC 29 ms
10,224 KB
testcase_03 WA -
testcase_04 AC 30 ms
10,224 KB
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 42 ms
10,580 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 932 ms
33,860 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 612 ms
26,852 KB
testcase_34 AC 610 ms
26,892 KB
testcase_35 AC 373 ms
18,060 KB
testcase_36 AC 355 ms
17,668 KB
testcase_37 AC 925 ms
35,020 KB
testcase_38 AC 931 ms
34,192 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 30 ms
10,224 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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匹の金魚をすくう場合
ans += (1 - ruiseki_p) * point[n]

print(ans % MOD)
    
0