結果

問題 No.66 輝け☆全国たこやき杯
ユーザー kroton
提出日時 2014-10-22 08:11:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,145 bytes
コンパイル時間 831 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 13:00:42
合計ジャッジ時間 1,644 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cstring>
using namespace std;
typedef long long ll;

int S[(1<<10)+10];
double dp[12][(1<<10)+10];

double prob(int A, int B){
    return 1.0 * A * A / (A * A + B * B);
}

int main(){
    int M;
    cin >> M;
    
    int N = 1 << M;
    for(int i=0;i<N;i++)cin >> S[i];
    for(int i=0;i<N;i++)dp[0][i] = 1;
    
    int len = 2;
    int half = 1;
    
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j+=len){
            int as = j;
            int at = as + half;
            int bs = at;
            int bt = bs + half;
            
            for(int a=as;a<at;a++)for(int b=bs;b<bt;b++){
                dp[i+1][a] += prob(S[a], S[b]) * dp[i][a] * dp[i][b];
                dp[i+1][b] += prob(S[b], S[a]) * dp[i][a] * dp[i][b];
            }
        }
        
        len <<= 1;
        half <<= 1;
    }
    
    printf("%.10f\n", dp[M][0]);
    return 0;
}
0