結果

問題 No.66 輝け☆全国たこやき杯
ユーザー sugim48sugim48
提出日時 2014-11-13 23:26:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,073 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 81,476 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:25:21
合計ジャッジ時間 1,653 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
double calc(int x, int y) {
	return (double)x * x / (x * x + y * y);
}
 
int main() {
	int K; cin >> K;
	int n = 1 << K;
	vector<int> R(n);
	for (int i = 0; i < n; i++) cin >> R[i];
	vector< vector<double> > dp(K + 1);
	dp[0].assign(n, 1);
	for (int k = 1; k <= K; k++) {
		dp[k].assign(n, 0);
		int m = 1 << (k - 1);
		for (int i = 0; i < n; i++)
			for (int j = m * ((i / m) ^ 1); j < m * ((i / m) ^ 1) + m; j++)
				dp[k][i] += dp[k - 1][i] * dp[k - 1][j] * calc(R[i], R[j]);
	}
	printf("%.10f\n", dp[K][0]);
}
0