結果

問題 No.66 輝け☆全国たこやき杯
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2014-11-14 00:27:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 942 bytes
コンパイル時間 553 ms
コンパイル使用メモリ 74,688 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:28:46
合計ジャッジ時間 1,235 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <numeric>
#include <ctime>
 
using namespace std;
 
double dp[11][1024];
 
double p[1024];
 
int main(){
	int k;
	
	cin >> k;
	
	for(int i = 0; i < pow(2, k); i++){
		cin >> p[i];
	}
	
	int n = pow(2, k);
	int b = 2;
	
	for(int i = 0; i < n; i++){
		dp[0][i] = 1.0;
	}
	
	for(int i = 0; i < k; i++){
		for(int j = 0; j < n; j += b){
			for(int t = j; t < j + b / 2; t++){
				for(int s = j + b / 2; s < j + b; s++){
					dp[i+1][t] += (p[t]*p[t] / (p[t]*p[t]+p[s]*p[s])) * dp[i][s] * dp[i][t];
					dp[i+1][s] += (p[s]*p[s] / (p[t]*p[t]+p[s]*p[s])) * dp[i][s] * dp[i][t];
				}
			}
		}
		
		b *= 2;
	}
	
	cout << dp[k][0] << endl;
	
	return 0;
}
0