結果

問題 No.66 輝け☆全国たこやき杯
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-20 19:03:49
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 951 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 142,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 02:53:51
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

int main(){

    long long M, N, vs, v;
    long double P, tot;
    cin >> M;
    N = 1LL<<M;
    vector<vector<long double>> dp(M+1, vector<long double>(N));

    for (int i=0; i<N; i++) dp[0][i] = 1.0;
    vector<long double> S(N);
    for (int i=0; i<N; i++) cin >> S[i];

    for (int i=1; i<=M; i++){
        for (int j=0; j<N; j++){
            tot = 0.0;
            vs = j/(1<<i) * (1<<i) + (1<<(i-1)) - (1<<(i-1) & j);
            for (int k=0; k<(1<<(i-1)); k++){
                v = vs+k;
                P = S[j]*S[j]/(S[v]*S[v]+S[j]*S[j]);
                tot += P * dp[i-1][v];
            }
            dp[i][j] = dp[i-1][j] * tot;
        }
    }

    cout << setprecision(18) << dp[M][0] << endl;

    return 0;
}
0