結果

問題 No.66 輝け☆全国たこやき杯
ユーザー h_nosonh_noson
提出日時 2016-03-23 14:01:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 873 bytes
コンパイル時間 548 ms
コンパイル使用メモリ 61,004 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 20:59:48
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

double prob(double a, double b) {
    return a*a/(a*a+b*b);
}

int main() {
    int i, j, k, m;
    double ans = 1;
    double s[1<<10];
    double p[11][1<<10];
    cin >> m;
    rep (i,1<<m) cin >> s[i];
    fill (p[0],p[0]+(1<<m),1);
    REP (i,1,m+1) {
        rep (j,1<<m) {
            p[i][j] = 0;
            int base = j/(1<<i)*(1<<i);
            rep (k,1<<i) {
                if (j/(1<<(i-1)) != (base+k)/(1<<(i-1)))
                    p[i][j] += p[i-1][base+k]*prob(s[j],s[base+k]);
            }
            p[i][j] *= p[i-1][j];
        }
    }
    cout << p[m][0] << endl;
    return 0;
}
0