結果

問題 No.766 金魚すくい
ユーザー kk
提出日時 2020-10-22 19:04:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 1,500 ms
コード長 1,316 bytes
コンパイル時間 2,706 ms
コンパイル使用メモリ 205,204 KB
実行使用メモリ 7,260 KB
最終ジャッジ日時 2023-09-28 14:45:27
合計ジャッジ時間 8,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
6,536 KB
testcase_01 AC 38 ms
6,464 KB
testcase_02 AC 37 ms
6,472 KB
testcase_03 AC 37 ms
6,496 KB
testcase_04 AC 37 ms
6,680 KB
testcase_05 AC 37 ms
6,472 KB
testcase_06 AC 37 ms
6,568 KB
testcase_07 AC 37 ms
6,496 KB
testcase_08 AC 37 ms
6,512 KB
testcase_09 AC 37 ms
6,536 KB
testcase_10 AC 37 ms
6,680 KB
testcase_11 AC 37 ms
6,460 KB
testcase_12 AC 37 ms
6,644 KB
testcase_13 AC 38 ms
6,720 KB
testcase_14 AC 37 ms
6,704 KB
testcase_15 AC 38 ms
6,524 KB
testcase_16 AC 37 ms
6,476 KB
testcase_17 AC 38 ms
6,528 KB
testcase_18 AC 38 ms
6,580 KB
testcase_19 AC 37 ms
6,528 KB
testcase_20 AC 38 ms
6,472 KB
testcase_21 AC 38 ms
6,476 KB
testcase_22 AC 38 ms
6,556 KB
testcase_23 AC 71 ms
6,984 KB
testcase_24 AC 71 ms
7,012 KB
testcase_25 AC 73 ms
7,172 KB
testcase_26 AC 69 ms
7,032 KB
testcase_27 AC 73 ms
7,000 KB
testcase_28 AC 70 ms
7,260 KB
testcase_29 AC 70 ms
7,020 KB
testcase_30 AC 70 ms
7,072 KB
testcase_31 AC 73 ms
7,064 KB
testcase_32 AC 70 ms
6,996 KB
testcase_33 AC 65 ms
7,084 KB
testcase_34 AC 65 ms
7,212 KB
testcase_35 AC 37 ms
6,524 KB
testcase_36 AC 37 ms
6,604 KB
testcase_37 AC 72 ms
6,960 KB
testcase_38 AC 71 ms
6,948 KB
testcase_39 AC 73 ms
7,140 KB
testcase_40 AC 70 ms
6,988 KB
testcase_41 AC 63 ms
6,928 KB
testcase_42 AC 62 ms
6,928 KB
testcase_43 AC 37 ms
6,456 KB
testcase_44 AC 37 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);
const long long MOD = 1e9 + 7;

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

long long f[200000];
long long g[200000];

long long homo(long long n, long long r) {
  long long x = n + r - 1;
  long long y = r;
  return f[x] * g[y] % MOD * g[x-y] % MOD;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  long long p;  // success
  long long q;  // failure
  cin >> n >> m >> q;

  q = q * modpow(100, MOD-2, MOD) % MOD;
  p = (1 - q + MOD) % MOD;

  vector<long long> v(n);
  REP (i, n) cin >> v[i];
  sort(v.rbegin(), v.rend());

  f[0] = g[0] = 1;
  for (int i = 1; i < 200000; i++) {
    f[i] = i * f[i-1] % MOD;
    g[i] = modpow(f[i], MOD-2, MOD);
  }
  
  long long ret = 0;
  long long acc = 1;
  REP (i, n) {
    long long tmp = homo(m, i) * modpow(p, i, MOD) % MOD * modpow(q, m, MOD) % MOD;
    acc = (acc - tmp + MOD) % MOD;
    ret += v[i] * acc % MOD;
    ret %= MOD;
  }
  cout << ret << endl;
  
  return 0;
}
0