結果

問題 No.766 金魚すくい
ユーザー kriiikriii
提出日時 2018-12-14 00:15:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 1,500 ms
コード長 897 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 45,376 KB
実行使用メモリ 8,268 KB
最終ジャッジ日時 2023-10-25 09:42:54
合計ジャッジ時間 2,929 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,880 KB
testcase_01 AC 11 ms
7,880 KB
testcase_02 AC 11 ms
7,880 KB
testcase_03 AC 11 ms
7,880 KB
testcase_04 AC 10 ms
7,880 KB
testcase_05 AC 11 ms
7,880 KB
testcase_06 AC 11 ms
7,880 KB
testcase_07 AC 12 ms
7,880 KB
testcase_08 AC 10 ms
7,880 KB
testcase_09 AC 11 ms
7,880 KB
testcase_10 AC 11 ms
7,880 KB
testcase_11 AC 11 ms
7,880 KB
testcase_12 AC 11 ms
7,880 KB
testcase_13 AC 11 ms
7,884 KB
testcase_14 AC 11 ms
7,888 KB
testcase_15 AC 10 ms
7,884 KB
testcase_16 AC 11 ms
7,884 KB
testcase_17 AC 11 ms
7,888 KB
testcase_18 AC 11 ms
7,884 KB
testcase_19 AC 12 ms
7,888 KB
testcase_20 AC 11 ms
7,884 KB
testcase_21 AC 11 ms
7,884 KB
testcase_22 AC 11 ms
7,888 KB
testcase_23 AC 30 ms
8,248 KB
testcase_24 AC 31 ms
8,248 KB
testcase_25 AC 33 ms
8,268 KB
testcase_26 AC 31 ms
8,232 KB
testcase_27 AC 32 ms
8,264 KB
testcase_28 AC 31 ms
8,236 KB
testcase_29 AC 31 ms
8,240 KB
testcase_30 AC 30 ms
8,236 KB
testcase_31 AC 33 ms
8,268 KB
testcase_32 AC 32 ms
8,240 KB
testcase_33 AC 32 ms
8,248 KB
testcase_34 AC 30 ms
8,252 KB
testcase_35 AC 12 ms
7,880 KB
testcase_36 AC 11 ms
7,880 KB
testcase_37 AC 31 ms
8,252 KB
testcase_38 AC 31 ms
8,248 KB
testcase_39 AC 31 ms
8,264 KB
testcase_40 AC 30 ms
8,240 KB
testcase_41 AC 23 ms
8,264 KB
testcase_42 AC 23 ms
8,244 KB
testcase_43 AC 10 ms
7,880 KB
testcase_44 AC 11 ms
7,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
using namespace std;

const long long mod = 1000000007;
int N,M,P,V[100100];
long long inv[200100]={0,1},fact[200100]={1,1},ifact[200100]={1,1};

int main()
{
	for (int i=2;i<200100;i++){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i-1] * i % mod;
		ifact[i] = ifact[i-1] * inv[i] % mod;
	}

	scanf ("%d %d %d",&N,&M,&P); P = P * inv[100] % mod;

	for (int i=0;i<N;i++) scanf ("%d",&V[i]);
	sort(V,V+N);
	reverse(V,V+N);

	long long ans = 0, sum = 1, have = 0, pw = 1, mul = 1;
	for (int i=1;i<=M;i++) mul = mul * P % mod;
	for (int i=0;i<=N;i++){
		long long c = pw * fact[i+M-1] % mod * ifact[M-1] % mod * ifact[i] % mod * mul % mod;
		ans = (ans + c * have) % mod;
		sum = (sum + mod - c) % mod;
		have = (have + V[i]) % mod;
		pw = pw * (mod + 1 - P) % mod;
	}
	ans = (ans + sum * have) % mod;
	printf ("%lld\n",ans);

	return 0;
}
0