結果

問題 No.766 金魚すくい
ユーザー chocopuuchocopuu
提出日時 2018-12-15 06:06:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 1,500 ms
コード長 2,777 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 171,312 KB
実行使用メモリ 18,112 KB
最終ジャッジ日時 2023-10-25 10:43:46
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
16,548 KB
testcase_01 AC 16 ms
16,548 KB
testcase_02 AC 17 ms
16,548 KB
testcase_03 AC 16 ms
16,548 KB
testcase_04 AC 17 ms
16,548 KB
testcase_05 AC 17 ms
16,548 KB
testcase_06 AC 16 ms
16,548 KB
testcase_07 AC 16 ms
16,548 KB
testcase_08 AC 15 ms
16,548 KB
testcase_09 AC 16 ms
16,548 KB
testcase_10 AC 15 ms
16,548 KB
testcase_11 AC 16 ms
16,548 KB
testcase_12 AC 16 ms
16,548 KB
testcase_13 AC 16 ms
16,572 KB
testcase_14 AC 16 ms
16,580 KB
testcase_15 AC 16 ms
16,572 KB
testcase_16 AC 16 ms
16,572 KB
testcase_17 AC 16 ms
16,580 KB
testcase_18 AC 17 ms
16,568 KB
testcase_19 AC 16 ms
16,576 KB
testcase_20 AC 16 ms
16,572 KB
testcase_21 AC 15 ms
16,572 KB
testcase_22 AC 17 ms
16,580 KB
testcase_23 AC 36 ms
18,028 KB
testcase_24 AC 34 ms
18,020 KB
testcase_25 AC 36 ms
18,096 KB
testcase_26 AC 34 ms
17,964 KB
testcase_27 AC 35 ms
18,092 KB
testcase_28 AC 34 ms
17,980 KB
testcase_29 AC 36 ms
17,988 KB
testcase_30 AC 35 ms
17,980 KB
testcase_31 AC 37 ms
18,112 KB
testcase_32 AC 36 ms
18,000 KB
testcase_33 AC 37 ms
18,028 KB
testcase_34 AC 36 ms
18,036 KB
testcase_35 AC 15 ms
16,548 KB
testcase_36 AC 16 ms
16,548 KB
testcase_37 AC 34 ms
18,036 KB
testcase_38 AC 35 ms
18,024 KB
testcase_39 AC 37 ms
18,088 KB
testcase_40 AC 35 ms
17,984 KB
testcase_41 AC 28 ms
18,084 KB
testcase_42 AC 27 ms
18,012 KB
testcase_43 AC 16 ms
16,548 KB
testcase_44 AC 15 ms
16,548 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;
int ans=0,sum=0;
int v[200010],s[200010],cnt[200010];

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];
        s[i+1]%=MOD;
    }
    
    int x=mod_inv(100);
    int xx=mod_pow(P*x%MOD,M);
    int xxx=1;
    int y=1;
    rep(i,0,N){
        int tmp=COM(i+M-1,M-1)*xx%MOD*xxx%MOD;
        (xxx*=(100-P)*x%MOD)%=MOD;
        (y+=MOD-tmp)%=MOD;
        y%=MOD;
        (ans+=(tmp*s[i])%MOD)%=MOD;
        ans%=MOD;
    }
    (ans+=(y*s[N]))%=MOD;
    cout<<ans%MOD<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}
0