結果

問題 No.66 輝け☆全国たこやき杯
ユーザー koyoprokoyopro
提出日時 2015-09-30 23:23:32
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 713 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 148,536 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 00:34:36
合計ジャッジ時間 2,539 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)

int M;
signed main()
{
    cin >> M;
    vector<int> S(1<<M);
    REP(i,1<<M) cin >> S[i];

    vector<double> P(1<<M, 1.0);
    REP(m,M) {
        // M回戦でそれぞれが勝つ確率を計算する
        vector<double> Q(1<<M, 0.0);
        REP(i,1<<M) {
            int ei = (i ^ (1<<m)) & ((1<<12)-(1<<m));
            REP(j, (1<<m)) {
                int ej = ei + j;
                Q[i] += P[ej] * pow(S[i], 2) / (pow(S[i],2) + pow(S[ej], 2));
            }
            Q[i] *= P[i];
        }
        P = Q;
    }

    printf("%.14f\n", P[0]);

    return 0;
}
0