結果

問題 No.1688 Veterinarian
ユーザー kotatsugamekotatsugame
提出日時 2021-09-24 21:33:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 3,000 ms
コード長 984 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 72,576 KB
実行使用メモリ 5,536 KB
最終ジャッジ日時 2023-09-18 20:48:03
合計ジャッジ時間 1,473 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4 ms
4,708 KB
testcase_08 AC 47 ms
5,508 KB
testcase_09 AC 43 ms
5,536 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
int A,B,C,N;
double dp[2][51][51][51];
main()
{
	cin>>A>>B>>C>>N;
	int now=0;
	dp[now][A][B][C]=1;
	for(int _=0;_<N;_++)
	{
		int nxt=1-now;
		for(int i=1;i<=A;i++)for(int j=1;j<=B;j++)for(int k=1;k<=C;k++)dp[nxt][i][j][k]=0;
		for(int i=1;i<=A;i++)for(int j=1;j<=B;j++)for(int k=1;k<=C;k++)
		{
			int n=i+j+k;
			int all=n*(n-1)/2;
			int usd=all;
			{
				int a=i*(i-1)/2;
				dp[nxt][i-1][j][k]+=dp[now][i][j][k]*a/all;
				usd-=a;
			}
			{
				int b=j*(j-1)/2;
				dp[nxt][i][j-1][k]+=dp[now][i][j][k]*b/all;
				usd-=b;
			}
			{
				int c=k*(k-1)/2;
				dp[nxt][i][j][k-1]+=dp[now][i][j][k]*c/all;
				usd-=c;
			}
			dp[nxt][i][j][k]+=dp[now][i][j][k]*usd/all;
		}
		now=nxt;
	}
	double a=0,b=0,c=0;
	for(int i=1;i<=A;i++)for(int j=1;j<=B;j++)for(int k=1;k<=C;k++)
	{
		a+=dp[now][i][j][k]*(A-i);
		b+=dp[now][i][j][k]*(B-j);
		c+=dp[now][i][j][k]*(C-k);
	}
	cout<<fixed<<setprecision(16)<<a<<" "<<b<<" "<<c<<endl;
}
0