結果

問題 No.66 輝け☆全国たこやき杯
ユーザー Ysmr_RyYsmr_Ry
提出日時 2014-12-29 14:56:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 608 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 27,424 KB
実行使用メモリ 11,248 KB
最終ジャッジ日時 2023-09-03 20:13:01
合計ジャッジ時間 788 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

const int MAX_M = 10;

int M;
double S[1<<MAX_M], dp[MAX_M+1][1<<MAX_M];
double P[1<<MAX_M][1<<MAX_M];

int main()
{
	scanf( "%d", &M );
	rep( i, 1<<M )
	{
		scanf( "%lf", S+i );
		dp[0][i] = 1.0;
	}

	rep( i, 1<<M ) rep( j, 1<<M )
		P[i][j] = (S[i]*S[i])/(S[i]*S[i]+S[j]*S[j]);

	rep( i, M ) rep( j, 1<<M )
	{
		int lb = j/(1<<i+1)*(1<<i+1),
			ub = lb+(1<<i+1),
			mid = lb+ub>>1;

		repi( k, j<mid?mid:lb, j<mid?ub:mid )
			dp[i+1][j] += dp[i][j]*dp[i][k]*P[j][k];
	}

	printf( "%.7f\n", dp[M][0] );

	return 0;
}
0