結果

問題 No.766 金魚すくい
ユーザー rickythetarickytheta
提出日時 2018-12-14 00:18:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 1,330 ms
コンパイル使用メモリ 162,732 KB
実行使用メモリ 9,208 KB
最終ジャッジ日時 2023-10-25 09:44:52
合計ジャッジ時間 3,700 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,628 KB
testcase_01 AC 7 ms
7,628 KB
testcase_02 AC 7 ms
7,628 KB
testcase_03 AC 7 ms
7,628 KB
testcase_04 AC 7 ms
7,628 KB
testcase_05 AC 7 ms
7,628 KB
testcase_06 AC 6 ms
7,628 KB
testcase_07 AC 7 ms
7,628 KB
testcase_08 AC 7 ms
7,628 KB
testcase_09 AC 7 ms
7,628 KB
testcase_10 AC 7 ms
7,628 KB
testcase_11 AC 7 ms
7,628 KB
testcase_12 AC 7 ms
7,628 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 7 ms
7,648 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 42 ms
9,096 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 7 ms
7,628 KB
testcase_36 AC 7 ms
7,628 KB
testcase_37 AC 44 ms
9,112 KB
testcase_38 AC 43 ms
9,100 KB
testcase_39 AC 46 ms
9,164 KB
testcase_40 AC 42 ms
9,060 KB
testcase_41 AC 37 ms
9,156 KB
testcase_42 AC 35 ms
9,088 KB
testcase_43 AC 7 ms
7,628 KB
testcase_44 AC 7 ms
7,628 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |   scanf("%d%d%d",&n,&m,&p);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:31:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |   REP(i,n)scanf("%lld",v+i);
      |           ~~~~~^~~~~~~~~~~~

ソースコード

diff #

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

typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))

const ll MOD = 1000000007;
ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}
ll modinv(ll a){return modpow(a,MOD-2);}

int n,m,p;
ll v[125252], vsum[125252];

ll fact[252521], ifact[252521];

int main(){
  scanf("%d%d%d",&n,&m,&p);
  REP(i,n)scanf("%lld",v+i);
  sort(v,v+n);
  reverse(v,v+n);
  REP(i,n)vsum[i+1] = vsum[i] + v[i];
  fact[0] = 1;
  FOR(i,1,252521)fact[i] = fact[i-1]*i%MOD;
  ifact[252520] = modinv(fact[252520]);
  FORR(i,0,252520)ifact[i] = ifact[i+1]*(i+1)%MOD;
  ll ans = 0;
  ll rest = 1;
  ll pp = p * modinv(100) % MOD;
  REP(i,n){
    // caught i fishes
    // -> i+m sequence
    // p^m * (1-p)^i * comb(i+m-1,i)
    ll po = modpow(pp,m) * modpow(1+MOD-pp,i) % MOD;
    po = po * fact[i+m-1] % MOD * ifact[m-1] % MOD * ifact[i] % MOD;
    rest = (rest + MOD - po) % MOD;
    ans = (ans + po * vsum[i] % MOD) % MOD;
  }
  (ans += rest * vsum[n] % MOD) %= MOD;
  printf("%lld\n",ans);
  return 0;
}
0