結果

問題 No.66 輝け☆全国たこやき杯
ユーザー mamekinmamekin
提出日時 2015-01-17 06:41:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,681 ms / 5,000 ms
コード長 1,153 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 93,692 KB
実行使用メモリ 15,524 KB
最終ジャッジ日時 2023-09-04 16:37:40
合計ジャッジ時間 5,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 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,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 9 ms
4,376 KB
testcase_07 AC 61 ms
4,380 KB
testcase_08 AC 463 ms
6,292 KB
testcase_09 AC 3,681 ms
15,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int m;
    cin >> m;
    int n = 1 << m;

    vector<double> s(n);
    for(int i=0; i<n; ++i){
        cin >> s[i];
        s[i] *= s[i];
    }

    vector<vector<double> > p(n, vector<double>(n, 0.0));
    for(int i=0; i<n; ++i)
        p[i][i] = 1.0;
    for(int i=0; i<m; ++i){
        vector<vector<double> > p2(p.size()/2, vector<double>(n, 0.0));
        for(unsigned j=0; j<p.size()/2; ++j){
            for(int a=0; a<n; ++a){
                for(int b=0; b<n; ++b){
                    p2[j][a] += p[j*2][a] * p[j*2+1][b] * s[a] / (s[a] + s[b]);
                    p2[j][b] += p[j*2][a] * p[j*2+1][b] * s[b] / (s[a] + s[b]);
                }
            }
        }
        p.swap(p2);
    }
    printf("%.10f\n", p[0][0]);

    return 0;
}
0