結果

問題 No.66 輝け☆全国たこやき杯
ユーザー kk
提出日時 2021-03-02 12:13:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 749 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 198,772 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 04:33:23
合計ジャッジ時間 3,049 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

double dp[11][1024];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int m;
  cin >> m;
  int n = 1<<m;

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

  for (int i = 0; i < n; i++)
    dp[0][i] = 1.0;

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j += 1<<(i+1)) {
      for (int x = j; x < j + (1<<i); x++) {
        for (int y = j + (1<<i); y < j + (1<<(i+1)); y++) {
          dp[i+1][x] += dp[i][x] * dp[i][y] * s[x] / (s[x] + s[y]);
          dp[i+1][y] += dp[i][x] * dp[i][y] * s[y] / (s[x] + s[y]);
        }
      }
    }
  }
  
  cout << fixed << setprecision(12) << dp[m][0] << endl;
  
  return 0;
}
0