結果

問題 No.66 輝け☆全国たこやき杯
ユーザー MicrobeMicrobe
提出日時 2017-09-07 13:58:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 1,228 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 164,412 KB
実行使用メモリ 11,928 KB
最終ジャッジ日時 2023-08-07 07:20:19
合計ジャッジ時間 2,288 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>  

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

double s[1025];
double dp[12][1025], w[1025][1025];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int m;
    cin >> m;
    rep(i, (1 << m)) cin >> s[i];
    rep(i, (1 << m)) rep(j, (1 << m)) {
        if(i == j) continue;
        w[i][j] = (s[i] * s[i]) / (s[i] * s[i] + s[j] * s[j]);
    }
    rep(i, 1025) dp[0][i] = 1.0;
    rep(i, m) rep(j, (1 << m)) rep(k, (1 << m)) {
        if((j >> i) != (k >> i) && (j >> (i + 1)) == (k >> (i + 1))) {
            dp[i + 1][j] += dp[i][j] * dp[i][k] * w[j][k];
         }
    }
    printf("%.9f\n", dp[m][0]);
    return 0;
}
0