結果

問題 No.766 金魚すくい
ユーザー chocopuuchocopuu
提出日時 2018-12-15 05:14:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,711 bytes
コンパイル時間 3,257 ms
コンパイル使用メモリ 171,340 KB
実行使用メモリ 17,908 KB
最終ジャッジ日時 2023-10-25 10:43:37
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
16,560 KB
testcase_01 AC 17 ms
16,560 KB
testcase_02 AC 17 ms
16,560 KB
testcase_03 AC 17 ms
16,560 KB
testcase_04 AC 17 ms
16,560 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 18 ms
16,572 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 52 ms
17,808 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 17 ms
16,560 KB
testcase_36 AC 17 ms
16,560 KB
testcase_37 AC 53 ms
17,824 KB
testcase_38 AC 53 ms
17,812 KB
testcase_39 AC 55 ms
17,880 KB
testcase_40 AC 52 ms
17,772 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 17 ms
16,560 KB
testcase_44 AC 16 ms
16,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,M,P,ans=0,sum=0;
int v[100010],s[100010],cnt[100010];

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

int mod_inv(int x)
{
	return mod_pow(x, MOD - 2);
}

signed main() {
    IOS();
    COMinit();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N>>M>>P;
    rep(i,0,N)cin>>v[i];
    sort(v,v+N);
    reverse(v,v+N);
    rep(i,0,N)s[i+1]=s[i]+v[i];
    
    int x=mod_inv(100);
    rep(i,0,N){
        int tmp=COM(i+M-1,i)*mod_pow((P*x)%MOD,M);
        tmp%=MOD;
        tmp*=mod_pow(((100-P)*x)%MOD,i);
        tmp%=MOD;
        sum+=tmp;
        tmp%=MOD;
        ans+=tmp*s[i];
        ans%=MOD;
    }
    ans+=((1-sum+MOD)%MOD)*s[N];
    cout<<ans%MOD<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}
0