結果

問題 No.766 金魚すくい
ユーザー qibqib
提出日時 2022-12-29 01:06:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 1,500 ms
コード長 852 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 99,788 KB
最終ジャッジ日時 2023-08-15 19:11:31
合計ジャッジ時間 8,346 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,276 KB
testcase_01 AC 62 ms
71,220 KB
testcase_02 AC 60 ms
71,328 KB
testcase_03 AC 61 ms
71,220 KB
testcase_04 AC 64 ms
71,292 KB
testcase_05 AC 63 ms
71,288 KB
testcase_06 AC 63 ms
71,292 KB
testcase_07 AC 63 ms
71,492 KB
testcase_08 AC 63 ms
71,344 KB
testcase_09 AC 66 ms
71,200 KB
testcase_10 AC 66 ms
71,484 KB
testcase_11 AC 63 ms
71,308 KB
testcase_12 AC 64 ms
71,092 KB
testcase_13 AC 76 ms
76,536 KB
testcase_14 AC 76 ms
76,576 KB
testcase_15 AC 76 ms
76,456 KB
testcase_16 AC 78 ms
76,552 KB
testcase_17 AC 76 ms
76,720 KB
testcase_18 AC 74 ms
75,968 KB
testcase_19 AC 77 ms
76,576 KB
testcase_20 AC 78 ms
76,468 KB
testcase_21 AC 79 ms
76,652 KB
testcase_22 AC 77 ms
76,532 KB
testcase_23 AC 137 ms
99,556 KB
testcase_24 AC 131 ms
99,592 KB
testcase_25 AC 139 ms
98,644 KB
testcase_26 AC 133 ms
98,224 KB
testcase_27 AC 140 ms
98,604 KB
testcase_28 AC 134 ms
97,864 KB
testcase_29 AC 136 ms
99,760 KB
testcase_30 AC 132 ms
98,104 KB
testcase_31 AC 138 ms
98,400 KB
testcase_32 AC 136 ms
99,600 KB
testcase_33 AC 119 ms
95,700 KB
testcase_34 AC 118 ms
95,588 KB
testcase_35 AC 75 ms
78,392 KB
testcase_36 AC 75 ms
78,188 KB
testcase_37 AC 132 ms
99,788 KB
testcase_38 AC 130 ms
99,668 KB
testcase_39 AC 134 ms
99,740 KB
testcase_40 AC 130 ms
99,416 KB
testcase_41 AC 131 ms
97,856 KB
testcase_42 AC 125 ms
97,688 KB
testcase_43 AC 62 ms
71,368 KB
testcase_44 AC 62 ms
71,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n, m, p = map(int, input().split())

l = max(n + m, 100)
fact = [1 for _ in range(l + 1)]
inv = [1 for _ in range(l + 1)]
ifact = [1 for _ in range(l + 1)]
for x in range(2, l + 1):
  fact[x] = (fact[x - 1] * x) % MOD
  inv[x] = (- (MOD // x) * inv[MOD % x]) % MOD
  ifact[x] = (ifact[x - 1] * inv[x]) % MOD

v = list(map(int, input().split()))
v.sort(reverse=True)

s = [0 for _ in range(n + 1)]
for i in range(n):
  s[i + 1] = (s[i] + v[i]) % MOD

pm = pow(p * inv[100], m, MOD)
prob = [0 for _ in range(n + 2)]
v = (100 - p) * inv[100] % MOD
cur = 1
for i in range(1, n + 1):
	prob[i] = fact[i + m - 2] * ifact[i - 1] * ifact[m - 1] % MOD
	prob[i] = (prob[i] * pm * cur) % MOD
	cur = (cur * v) % MOD

prob[n + 1] = (1 - sum(prob) % MOD) % MOD

ans = 0
for i in range(1, n + 2):
  ans = (ans + prob[i] * s[i - 1]) % MOD

print(ans)
0