結果

問題 No.66 輝け☆全国たこやき杯
ユーザー ty70ty70
提出日時 2016-10-21 15:42:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 875 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 164,152 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 10:25:53
合計ジャッジ時間 2,822 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int S[1<<10];
double dp[11][1<<10];

double calc_p(int i, int j){
	return (double)S[i]*S[i] / (double)(S[i]*S[i] + S[j]*S[j]);
}  

int main()
{
	memset(S, 0, sizeof(S));
	memset(dp, 0., sizeof(dp));
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int M; cin >> M;
	rep (i, 1<<M) cin >> S[i];
	rep (i, 1<<M) dp[0][i] = 1.;

	for (int k = 1; k <= M; ++k){
		for (int i = 0; i < (1<<M); ++i){
			int l = (i>>k)<<k, r = l + (1<<k);
			if (i >= (l+r) / 2)
				r = (l + r) / 2;
			else
				l = (l + r) / 2;
			double p = 0.;
			for (int j = l; j < r; ++j){
				p += dp[k-1][j] * calc_p(i,j);
			} // end for
			dp[k][i] = p*dp[k-1][i];
		} // end for
	} // end for

	printf("%.8lf\n", dp[M][0]);	
		
	return 0;
}
0