結果
問題 | No.766 金魚すくい |
ユーザー | neterukun |
提出日時 | 2019-06-04 23:09:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,655 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 81,808 KB |
実行使用メモリ | 112,716 KB |
最終ジャッジ日時 | 2023-10-17 23:51:38 |
合計ジャッジ時間 | 8,668 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
53,608 KB |
testcase_01 | AC | 37 ms
53,608 KB |
testcase_02 | AC | 37 ms
53,608 KB |
testcase_03 | AC | 36 ms
53,608 KB |
testcase_04 | AC | 36 ms
53,608 KB |
testcase_05 | AC | 37 ms
53,608 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 37 ms
53,608 KB |
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 | 57 ms
66,732 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 257 ms
112,288 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 | WA | - |
testcase_34 | WA | - |
testcase_35 | AC | 122 ms
71,652 KB |
testcase_36 | AC | 118 ms
71,452 KB |
testcase_37 | AC | 257 ms
112,048 KB |
testcase_38 | AC | 259 ms
112,288 KB |
testcase_39 | AC | 260 ms
112,404 KB |
testcase_40 | AC | 253 ms
111,424 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 37 ms
53,608 KB |
testcase_44 | AC | 36 ms
53,608 KB |
ソースコード
#Combinationクラス class Combination: ''' 計算量:階乗・逆元テーブルの作成O(N) nCkを求めるO(1) ''' 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(m+n, MOD) point = [0]*(n+1) v = sorted(v, reverse = True) for i in range(n): point[i+1] = point[i] + v[i] li_100 = [1]*(m+n+1) li_p = [1]*(m+n+1) li_100_p = [1]*(m+n+1) for i in range(m+n): li_100[i+1] = li_100[i]*100 li_p[i+1] = li_p[i]*p li_100_p[i+1] = li_100[i]*(100-p) li_100[i+1] %= MOD li_p[i+1] %= MOD li_100_p[i+1] %= MOD b = (li_100[m] * li_100[m] * li_100[n]) % MOD a = 0 kakuritu = 0 # 0~n-1匹の金魚をすくったとき for i in range(n): kakuritu += li_100[m+n-i] * li_p[m] * li_100_p[i] * comb.combination(m-1+i, i) a += li_100[m+n-i] * li_p[m] * li_100_p[i] * point[i] * comb.combination(m-1+i, i) a %= MOD kakuritu %= MOD #n匹の金魚をすくったとき a += (b - kakuritu) * point[n] a = a % MOD print((a * pow(b ,MOD-2 , MOD)) % MOD)