結果

問題 No.108 トリプルカードコンプ
ユーザー kotatsugamekotatsugame
提出日時 2020-03-02 22:02:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 550 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 71,364 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-21 22:52:11
合計ジャッジ時間 1,469 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 10 ms
9,088 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 8 ms
7,168 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
double dp[101][101][101];
bool vis[101][101][101];
int N;
double f(int x,int y,int z)
{
	if(x<0||y<0||z<0||x+y+z>N)return 0;
	if(vis[x][y][z])return dp[x][y][z];
	if(!x&&!y&&!z)return 0;
	dp[x][y][z]=(x*f(x-1,y+1,z)+y*f(x,y-1,z+1)+z*f(x,y,z-1)+N)/(double)(x+y+z);
	vis[x][y][z]=true;
	return dp[x][y][z];
}
main()
{
	cin>>N;
	int I=0,J=0,K=0;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		if(A==0)I++;
		else if(A==1)J++;
		else if(A==2)K++;
	}
	cout<<fixed<<setprecision(16)<<f(I,J,K)<<endl;
}
0