結果

問題 No.162 8020運動
ユーザー motimoti
提出日時 2015-04-14 12:19:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,236 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 53,520 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-17 20:09:58
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 41 ms
4,376 KB
testcase_12 AC 20 ms
4,380 KB
testcase_13 AC 82 ms
4,380 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 65 ms
4,376 KB
testcase_22 AC 61 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <assert.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

double P[3];
double dp[22][15];

double solve(int depth, int num) {

    if(depth == 0) { return num; }

    double& ret = dp[depth][num];
    if(ret >= 0) { return ret; }

    if(num == 1) { return ret = solve(depth-1, 1)*(1.0-P[0]); }

    ret = 0.;
    rep(S, 1<<num) {
        double prob = 1.0;
        rep(i, num) {
            double bad = (i==0||i==num-1) ? P[1] : P[2];
            if(S && (1<<i)) { prob *= 1.0-bad;  }
            else            { prob *= bad;      }
        }

        int next_num = 0;
        rep(i, num) {
            if(S & (1<<i)) {
                next_num ++;
            }
            else {
                if(next_num) {
                    ret += solve(depth-1, next_num) * prob;
                }
                next_num = 0;
            }
        }
        if(next_num) {
            ret += solve(depth-1, next_num) * prob;
        }
    }
    return ret;
}

int main() {
    int year; cin >> year;
    rep(i, 3) { cin >> P[i]; P[i] /= 100.0; }
    rep(i, 22) rep(j, 15) { dp[i][j] = -1.0; }
    printf("%.9lf\n", solve(80-year, 14) * 2.0);
    return 0;
}
0