結果

問題 No.66 輝け☆全国たこやき杯
ユーザー hotpepsihotpepsi
提出日時 2015-07-26 22:08:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 851 bytes
コンパイル時間 1,328 ms
コンパイル使用メモリ 66,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 23:42:03
合計ジャッジ時間 1,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	cout.precision(12);
	int M;
	cin >> M;
	M = 1 << M;
	double S[1024];
	double P[2][1024];
	vector<int> G[2][1024];
	for (int i = 0; i < M; ++i) {
		cin >> S[i];
		S[i] *= S[i];
		P[0][i] = 1.0;
		G[0][i].push_back(i);
	}
	int prev = 0, curr = 1;
	while (M > 1) {
		for (int i = 0; i < M / 2; ++i) {
			G[curr][i].clear();
		}
		for (int i = 0; i < M; ++i) {
			vector<int> &v = G[prev][i];
			vector<int> &opp = G[prev][i ^ 1];
			for (int j : v) {
				double p = 0;
				for (int k : opp) {
					p += P[prev][j] * P[prev][k] * S[j] / (S[j] + S[k]);
				}
				P[curr][j] = p;
				G[curr][i / 2].push_back(j);
			}
		}
		M /= 2;
		prev ^= 1, curr ^= 1;
	}
	double ans = P[prev][0];
	cout << ans << endl;
	return 0;
}
0