結果

問題 No.162 8020運動
ユーザー tkzw_21tkzw_21
提出日時 2015-03-18 12:46:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 1,211 bytes
コンパイル時間 1,478 ms
コンパイル使用メモリ 145,460 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 08:33:02
合計ジャッジ時間 4,562 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 49 ms
4,380 KB
testcase_02 AC 74 ms
4,380 KB
testcase_03 AC 98 ms
4,380 KB
testcase_04 AC 98 ms
4,376 KB
testcase_05 AC 99 ms
4,376 KB
testcase_06 AC 99 ms
4,376 KB
testcase_07 AC 98 ms
4,376 KB
testcase_08 AC 99 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 74 ms
4,380 KB
testcase_11 AC 49 ms
4,380 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 99 ms
4,380 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 10 ms
4,376 KB
testcase_16 AC 29 ms
4,380 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 94 ms
4,380 KB
testcase_19 AC 69 ms
4,380 KB
testcase_20 AC 79 ms
4,376 KB
testcase_21 AC 79 ms
4,380 KB
testcase_22 AC 74 ms
4,380 KB
testcase_23 AC 79 ms
4,376 KB
testcase_24 AC 74 ms
4,380 KB
testcase_25 AC 83 ms
4,376 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 53 ms
4,376 KB
testcase_28 AC 94 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//ドワンゴ フィッシング 8020
//SYAKYO
//http://yukicoder.me/submissions/12291
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};

double memo[100][100];
int P[3];

double func(int y,int n){
	if(y == 0)return n;
	if(memo[y][n] >= 0)return memo[y][n];

	if(n == 1){
		memo[y][n] = (100-P[0])/100. * func(y-1,1);
	}else{
		memo[y][n] = 0;
		for(int mk=0;mk < (1<<n);mk++){
			double prob = 1;
			for(int i=0;i<n;i++){
				double bad;
				if(i==0 || i==n-1)
					bad = P[1] / 100.0;
				else
					bad = P[2] / 100.0;

				if(mk & (1<<i))
					prob *= 1-bad;
				else
					prob *= bad;
			}

			int left = 0;
			for(int i=0;i<n;i++){
				if(mk & (1<<i)){
					left++;
				}
				else{
					if(left > 0)
						memo[y][n] += prob * func(y-1,left);
					left = 0;
				}
			}
			if(left > 0)
				memo[y][n] += prob * func(y-1,left);
		}
	}
	return memo[y][n];

}

int main(void) {	
	int A;cin >> A;
	cin >> P[0] >> P[1] >> P[2];
	for(int i=0;i<100;i++)for(int j=0;j<100;j++)memo[i][j] = -1;
	cout << fixed << setprecision(10) << func(80-A, 14) * 2.<< endl;

	return 0;
}

0