結果

問題 No.766 金魚すくい
ユーザー finefine
提出日時 2018-12-14 13:50:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 175,520 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-10-25 09:58:22
合計ジャッジ時間 3,915 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,720 KB
testcase_01 AC 2 ms
5,720 KB
testcase_02 AC 2 ms
5,720 KB
testcase_03 AC 2 ms
5,720 KB
testcase_04 AC 3 ms
5,720 KB
testcase_05 AC 2 ms
5,720 KB
testcase_06 AC 2 ms
5,724 KB
testcase_07 AC 2 ms
5,720 KB
testcase_08 AC 2 ms
5,720 KB
testcase_09 AC 3 ms
5,724 KB
testcase_10 AC 2 ms
5,720 KB
testcase_11 AC 3 ms
5,724 KB
testcase_12 AC 2 ms
5,724 KB
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 2 ms
5,772 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 26 ms
7,952 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 4 ms
6,384 KB
testcase_36 AC 4 ms
6,384 KB
testcase_37 AC 26 ms
7,952 KB
testcase_38 AC 26 ms
7,952 KB
testcase_39 AC 27 ms
7,952 KB
testcase_40 AC 25 ms
7,688 KB
testcase_41 AC 18 ms
7,952 KB
testcase_42 AC 17 ms
7,688 KB
testcase_43 AC 2 ms
5,720 KB
testcase_44 AC 2 ms
5,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll f[200005], fi[200005];

ll comb(int r, int c) {
    if (r < c) return 0;
    return f[r] * fi[c] % MOD * fi[r - c] % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, p;
    cin >> n >> m >> p;

    vector<ll> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.rbegin(), v.rend());

    vector<ll> sum(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + v[i - 1];
    }

    f[0] = 1;
    for (int i = 1; i <= n + m; i++) {
        f[i] = f[i - 1] * i % MOD;
    }
    fi[n + m] = modpow(f[n + m], MOD - 2);
    for (int i = n + m; i > 0; i--) {
        fi[i - 1] = fi[i] * i % MOD;
    }

    ll inv100 = modpow(100, MOD - 2);
    ll hoge = modpow(p * inv100 % MOD, m);
    ll foo = 1;
    ll per_n = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll tmp = comb(i + m - 1, m - 1) * hoge % MOD * foo % MOD;
        (per_n += MOD - tmp) %= MOD;
        (ans += tmp * sum[i] % MOD) %= MOD;
        (foo *= (100 - p) * inv100 % MOD) %= MOD;
    }
    (ans += per_n * sum[n] % MOD) %= MOD;
    cout << ans << endl;
    return 0;
}
0