結果

問題 No.766 金魚すくい
ユーザー rlangevinrlangevin
提出日時 2023-07-11 12:27:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 351 ms / 1,500 ms
コード長 845 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 96,728 KB
最終ジャッジ日時 2023-10-11 03:38:28
合計ジャッジ時間 13,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
79,540 KB
testcase_01 AC 89 ms
79,360 KB
testcase_02 AC 89 ms
79,216 KB
testcase_03 AC 88 ms
79,244 KB
testcase_04 AC 88 ms
79,340 KB
testcase_05 AC 89 ms
79,336 KB
testcase_06 AC 89 ms
79,352 KB
testcase_07 AC 90 ms
79,340 KB
testcase_08 AC 89 ms
79,324 KB
testcase_09 AC 88 ms
79,136 KB
testcase_10 AC 87 ms
79,424 KB
testcase_11 AC 89 ms
79,216 KB
testcase_12 AC 86 ms
79,308 KB
testcase_13 AC 104 ms
80,208 KB
testcase_14 AC 105 ms
80,032 KB
testcase_15 AC 103 ms
80,088 KB
testcase_16 AC 105 ms
80,100 KB
testcase_17 AC 105 ms
79,876 KB
testcase_18 AC 94 ms
79,248 KB
testcase_19 AC 106 ms
80,084 KB
testcase_20 AC 105 ms
80,088 KB
testcase_21 AC 103 ms
80,124 KB
testcase_22 AC 106 ms
79,912 KB
testcase_23 AC 333 ms
96,064 KB
testcase_24 AC 283 ms
96,500 KB
testcase_25 AC 343 ms
96,640 KB
testcase_26 AC 321 ms
94,552 KB
testcase_27 AC 351 ms
96,356 KB
testcase_28 AC 324 ms
94,428 KB
testcase_29 AC 336 ms
96,340 KB
testcase_30 AC 316 ms
94,768 KB
testcase_31 AC 343 ms
96,092 KB
testcase_32 AC 334 ms
96,040 KB
testcase_33 AC 229 ms
96,724 KB
testcase_34 AC 229 ms
96,720 KB
testcase_35 AC 89 ms
79,212 KB
testcase_36 AC 88 ms
79,360 KB
testcase_37 AC 310 ms
96,196 KB
testcase_38 AC 295 ms
96,376 KB
testcase_39 AC 305 ms
96,728 KB
testcase_40 AC 293 ms
96,444 KB
testcase_41 AC 336 ms
95,152 KB
testcase_42 AC 321 ms
94,852 KB
testcase_43 AC 89 ms
79,304 KB
testcase_44 AC 88 ms
79,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = 205050
mod = 10 ** 9 + 7
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

N, M, P = map(int, input().split())
V = list(map(int, input().split()))
V.sort(reverse=True)
Vc = [0] * (N + 1)
for i in range(N):
    Vc[i + 1] = Vc[i] + V[i]

ans = 0
P = P * pow(100, mod - 2, mod) % mod
nokori = 1
for i in range(N):
    ans += Vc[i] * pow(P, M, mod) * pow(1 - P, i, mod) * comb(M + i - 1, i)
    ans %= mod
    nokori -= pow(P, M, mod) * pow(1 - P, i, mod) * comb(M + i - 1, i)
    nokori %= mod

ans += Vc[-1] * nokori
ans %= mod

print(ans)
0