結果

問題 No.766 金魚すくい
ユーザー chocoruskchocorusk
提出日時 2018-12-14 00:41:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 1,500 ms
コード長 1,303 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 100,076 KB
実行使用メモリ 8,124 KB
最終ジャッジ日時 2023-10-25 09:46:15
合計ジャッジ時間 4,254 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,124 KB
testcase_01 AC 4 ms
8,124 KB
testcase_02 AC 5 ms
8,124 KB
testcase_03 AC 4 ms
8,124 KB
testcase_04 AC 5 ms
8,124 KB
testcase_05 AC 5 ms
8,124 KB
testcase_06 AC 4 ms
8,124 KB
testcase_07 AC 4 ms
8,124 KB
testcase_08 AC 4 ms
8,124 KB
testcase_09 AC 5 ms
8,124 KB
testcase_10 AC 5 ms
8,124 KB
testcase_11 AC 5 ms
8,124 KB
testcase_12 AC 4 ms
8,124 KB
testcase_13 AC 5 ms
8,124 KB
testcase_14 AC 6 ms
8,124 KB
testcase_15 AC 5 ms
8,124 KB
testcase_16 AC 5 ms
8,124 KB
testcase_17 AC 6 ms
8,124 KB
testcase_18 AC 5 ms
8,124 KB
testcase_19 AC 5 ms
8,124 KB
testcase_20 AC 5 ms
8,124 KB
testcase_21 AC 5 ms
8,124 KB
testcase_22 AC 6 ms
8,124 KB
testcase_23 AC 67 ms
8,124 KB
testcase_24 AC 67 ms
8,124 KB
testcase_25 AC 71 ms
8,124 KB
testcase_26 AC 64 ms
8,124 KB
testcase_27 AC 71 ms
8,124 KB
testcase_28 AC 65 ms
8,124 KB
testcase_29 AC 66 ms
8,124 KB
testcase_30 AC 66 ms
8,124 KB
testcase_31 AC 71 ms
8,124 KB
testcase_32 AC 66 ms
8,124 KB
testcase_33 AC 60 ms
8,124 KB
testcase_34 AC 60 ms
8,124 KB
testcase_35 AC 6 ms
8,124 KB
testcase_36 AC 6 ms
8,124 KB
testcase_37 AC 68 ms
8,124 KB
testcase_38 AC 67 ms
8,124 KB
testcase_39 AC 70 ms
8,124 KB
testcase_40 AC 65 ms
8,124 KB
testcase_41 AC 44 ms
8,124 KB
testcase_42 AC 42 ms
8,124 KB
testcase_43 AC 4 ms
8,124 KB
testcase_44 AC 5 ms
8,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
int main()
{
	int n, m; ll p;
	cin>>n>>m>>p;
	p=p*inv(100ll)%MOD;
	ll f[200001]; f[0]=1;
	for(ll i=1; i<=m+n; i++) f[i]=f[i-1]*i%MOD;
	ll invf[200001];
	invf[m+n]=inv(f[m+n]);
	for(ll i=m+n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
	ll s[100001]; s[0]=0;
	ll v[100001];
	for(int i=0; i<n; i++){
		cin>>v[i];
	}
	sort(v, v+n, greater<ll>());
	for(int i=0; i<n; i++) s[i+1]=(s[i]+v[i])%MOD;
	ll ans=0;
	ll ps=0;
	for(int i=0; i<=n-1; i++){
		ll q=f[i+m-1]*invf[i]%MOD*invf[m-1]%MOD*powmod((1-p+MOD)%MOD, (ll)i)%MOD*powmod(p, (ll)m)%MOD;
		ps=(ps+q)%MOD;
		ans+=(q*s[i]%MOD);
		ans%=MOD;
	}
	ans+=((1-ps+MOD)%MOD*s[n]%MOD);
	ans%=MOD;
	cout<<ans<<endl;
	return 0;
}
0