結果

問題 No.66 輝け☆全国たこやき杯
ユーザー mamekinmamekin
提出日時 2015-01-17 07:52:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,566 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 94,360 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 16:40:42
合計ジャッジ時間 1,622 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 4 ms
4,376 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<vector<pair<double, double> > > s(n, vector<pair<double, double> >(1));
    for(int i=0; i<n; ++i){
        cin >> s[i][0].first;
        s[i][0].first *= s[i][0].first;
        s[i][0].second = 1.0;
    }

    for(int i=0; i<m; ++i){
        vector<vector<pair<double, double> > > s2(n/(2<<i), vector<pair<double, double> >(2<<i));
        for(int j=0; j<n/(2<<i); ++j){
            for(int a=0; a<(1<<i); ++a){
                s2[j][a].first        = s[j*2][a].first;
                s2[j][(1<<i)+a].first = s[j*2+1][a].first;
            }
            
            for(int a=0; a<(1<<i); ++a){
                for(int b=0; b<(1<<i); ++b){
                    double sa = s[j*2][a].first;
                    double sb = s[j*2+1][b].first;
                    double pa = s[j*2][a].second;
                    double pb = s[j*2+1][b].second;
                    s2[j][a].second        += pa * pb * sa / (sa + sb);
                    s2[j][(1<<i)+b].second += pa * pb * sb / (sa + sb);
                }
            }
        }
        s.swap(s2);
    }
    printf("%.10f\n", s[0][0].second);

    return 0;
}
0