結果

問題 No.66 輝け☆全国たこやき杯
ユーザー pekempeypekempey
提出日時 2015-08-20 17:15:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 877 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 144,252 KB
実行使用メモリ 5,736 KB
最終ジャッジ日時 2023-09-25 13:54:52
合計ジャッジ時間 1,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,640 KB
testcase_01 AC 2 ms
5,720 KB
testcase_02 AC 2 ms
5,720 KB
testcase_03 AC 2 ms
5,736 KB
testcase_04 AC 2 ms
5,624 KB
testcase_05 AC 2 ms
5,692 KB
testcase_06 AC 2 ms
5,620 KB
testcase_07 AC 3 ms
5,712 KB
testcase_08 AC 3 ms
5,684 KB
testcase_09 AC 8 ms
5,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int M;
double S[101010];

double dp[20][101010];

double sq(double x) { 
	return x * x;
}

int main() {
	cin >> M;
	rep (i, 1 << M) cin >> S[i];

	rep (i, 1 << M) dp[0][i] = 1;

	rep (i, M) {
		rep (j, 1 << M) {
			int l = j / (1 << i + 1) * (1 << i + 1);
			int r = l + (1 << i + 1);
			int l2 = j / (1 << i) * (1 << i);
			int r2 = l2 + (1 << i);
			
			rep2 (k, l, r) if (k < l2 || r2 <= k) {
				double p = sq(S[j]) / (sq(S[j]) + sq(S[k]));
				dp[i + 1][j] += dp[i][j] * dp[i][k] * p; 
			}
		}	
	}

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

	return 0;
}
0