結果

問題 No.66 輝け☆全国たこやき杯
コンテスト
ユーザー Unbakedbread
提出日時 2025-12-30 00:21:37
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 806 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,726 ms
コンパイル使用メモリ 279,268 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-30 00:21:42
合計ジャッジ時間 3,760 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(void) {
	cout << fixed << setprecision(20);
	
	int M;
	cin >> M;
	vector<double> S(1 << M);
	for(int i = 0; i < (1 << M); ++i) cin >> S[i];
	
	auto calc = [&](int i, int j) ->double {
		return (S[i] * S[i]) / (S[i] * S[i] + S[j] * S[j]);
	};
	
	vector<double> c(1 << M, 1);
	auto dfs = [&](auto &&dfs, int t, int s) ->void {
		if(t == -1) return;
		
		dfs(dfs, t - 1, s);
		dfs(dfs, t - 1, s + (1 << t));
		
		vector<double> nc(1 << (t + 1), 0);
		for(int i = 0; i < (1 << t); ++i) for(int j = (1 << t); j < (1 << (t + 1)); ++j) {
			nc[i] += c[s + j] * calc(s + i, s + j);
			nc[j] += c[s + i] * calc(s + j, s + i);
		} 
		
		for(int i = 0; i < (1 << (t + 1)); ++i) c[s + i] *= nc[i];
	};
	dfs(dfs, M - 1, 0);
	
	cout << c[0] << "\n";
	
	return 0;
}
0