結果

問題 No.66 輝け☆全国たこやき杯
ユーザー krotonkroton
提出日時 2014-10-22 08:11:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,145 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 73,956 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 22:32:57
合計ジャッジ時間 1,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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