結果

問題 No.1688 Veterinarian
ユーザー publflpublfl
提出日時 2021-09-24 21:51:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 121 ms / 3,000 ms
コード長 835 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 32,964 KB
実行使用メモリ 202,908 KB
最終ジャッジ日時 2023-09-18 21:12:31
合計ジャッジ時間 1,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,064 KB
testcase_01 AC 23 ms
105,616 KB
testcase_02 AC 7 ms
29,952 KB
testcase_03 AC 2 ms
5,132 KB
testcase_04 AC 2 ms
5,016 KB
testcase_05 AC 2 ms
5,076 KB
testcase_06 AC 24 ms
106,548 KB
testcase_07 AC 2 ms
5,096 KB
testcase_08 AC 121 ms
202,908 KB
testcase_09 AC 106 ms
195,528 KB
testcase_10 AC 32 ms
96,416 KB
testcase_11 AC 16 ms
54,440 KB
testcase_12 AC 2 ms
7,100 KB
testcase_13 AC 16 ms
58,344 KB
testcase_14 AC 4 ms
17,480 KB
testcase_15 AC 46 ms
122,868 KB
testcase_16 AC 5 ms
19,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int check[51][51][51][51][4];
double check2[51][51][51][51][4];
double func(int k, int a, int b, int c, int mode)
{
	if(a<=0) return 0;
	if(b<=0) return 0;
	if(c<=0) return 0;
	if(k==0) return 0;
	if(check[k][a][b][c][mode]) return check2[k][a][b][c][mode];
	
	int s1 = a*(a-1)/2;
	int s2 = b*(b-1)/2;
	int s3 = c*(c-1)/2;
	int t = (a+b+c)*(a+b+c-1)/2;
	
	double val1 = func(k-1,a-1,b,c,mode)*s1/t + func(k-1,a,b-1,c,mode)*s2/t + func(k-1,a,b,c-1,mode)*s3/t;
	double val2 = func(k-1,a,b,c,mode)*(t-s1-s2-s3)/t;
	if(mode==1) val1 += (double)s1/t;
	if(mode==2) val1 += (double)s2/t;
	if(mode==3) val1 += (double)s3/t;
	check[k][a][b][c][mode] = 1;
	return check2[k][a][b][c][mode] = val1+val2;
}

int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	for(int i=1;i<=3;i++) printf("%.12lf ",func(d,a,b,c,i));
}
0