結果

問題 No.766 金魚すくい
ユーザー mkawa2mkawa2
提出日時 2020-08-28 00:07:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 1,500 ms
コード長 1,754 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 171,148 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 07:25:14
合計ジャッジ時間 4,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 3 ms
6,940 KB
testcase_15 AC 3 ms
6,940 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 72 ms
6,944 KB
testcase_24 AC 70 ms
6,940 KB
testcase_25 AC 73 ms
6,940 KB
testcase_26 AC 68 ms
6,940 KB
testcase_27 AC 73 ms
6,944 KB
testcase_28 AC 68 ms
6,940 KB
testcase_29 AC 69 ms
6,944 KB
testcase_30 AC 68 ms
6,940 KB
testcase_31 AC 74 ms
6,940 KB
testcase_32 AC 68 ms
6,940 KB
testcase_33 AC 70 ms
6,944 KB
testcase_34 AC 71 ms
6,940 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,944 KB
testcase_37 AC 72 ms
6,944 KB
testcase_38 AC 70 ms
6,940 KB
testcase_39 AC 72 ms
6,940 KB
testcase_40 AC 68 ms
6,944 KB
testcase_41 AC 45 ms
6,944 KB
testcase_42 AC 43 ms
6,944 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const ll inf = 1e9;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n,m;
  mint p;
  cin>>n>>m>>p;
  p=p/100;
  vi v(n);
  rep(i,n) cin>>v[i];
  sort(v.rbegin(),v.rend());
  mint ans;
  mint q=mint(1)-p;
  mint a=p.pow(m);
  mint b(1);
  mint c(1);
  mint s;
  mint rp(1);
  rep(i,n){
    ans+=a*b*c*s;
    rp-=a*b*c;
    b*=q;
    c=c*(m+i)/(i+1);
    s+=v[i];
    // cout<<"a "<<a<<" b "<<b<<" c "<<c<<" s "<<s<<" rp "<<rp<<endl;
  }
  ans+=rp*s;
  cout<<ans<<endl;
  return 0;
}
0