結果
| 問題 |
No.162 8020運動
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-04-14 12:19:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,236 bytes |
| コンパイル時間 | 466 ms |
| コンパイル使用メモリ | 58,700 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 14:23:14 |
| 合計ジャッジ時間 | 2,994 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 6 WA * 20 |
ソースコード
#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;
}
moti