結果

問題 No.66 輝け☆全国たこやき杯
ユーザー furafura
提出日時 2020-06-07 13:03:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 203,532 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 10:30:11
合計ジャッジ時間 3,052 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 26 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int m; scanf("%d",&m);
	int n=1<<m;
	vector<double> a(n);
	rep(i,n) scanf("%lf",&a[i]), a[i]*=a[i];

	// dp[i][j] = 人 j が i 回戦後に残っている確率
	vector<vector<double>> dp(m+1,vector<double>(n));
	rep(j,n) dp[0][j]=1;
	rep(i,m) rep(j,n) {
		rep(k,n) if(j!=k) {
			int t;
			for(t=m-1;(j>>t&1)==(k>>t&1);t--);
			if(t==i){
				dp[i+1][j]+=dp[i][j]*dp[i][k]*a[j]/(a[j]+a[k]);
			}
		}
	}
	printf("%.9f\n",dp[m][0]);

	return 0;
}
0