結果

問題 No.162 8020運動
ユーザー sugim48sugim48
提出日時 2015-03-06 00:23:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 1,518 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 91,796 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 15:24:21
合計ジャッジ時間 4,114 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,384 KB
testcase_01 AC 60 ms
4,380 KB
testcase_02 AC 91 ms
4,380 KB
testcase_03 AC 121 ms
4,384 KB
testcase_04 AC 121 ms
4,380 KB
testcase_05 AC 121 ms
4,380 KB
testcase_06 AC 122 ms
4,380 KB
testcase_07 AC 121 ms
4,380 KB
testcase_08 AC 121 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 90 ms
4,380 KB
testcase_11 AC 60 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 121 ms
4,380 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 11 ms
4,384 KB
testcase_16 AC 35 ms
4,376 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 115 ms
4,376 KB
testcase_19 AC 84 ms
4,376 KB
testcase_20 AC 97 ms
4,380 KB
testcase_21 AC 97 ms
4,384 KB
testcase_22 AC 90 ms
4,376 KB
testcase_23 AC 97 ms
4,380 KB
testcase_24 AC 91 ms
4,380 KB
testcase_25 AC 103 ms
4,376 KB
testcase_26 AC 5 ms
4,388 KB
testcase_27 AC 66 ms
4,380 KB
testcase_28 AC 116 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

double P0, P1, P2;

double f(int n, int k, vector<vector<double> >& memo) {
	if (memo[n][k] >= 0) return memo[n][k];
	if (k == 0) return memo[n][k] = n;
	double ans = 0;
	for (int S = 0; S < (1 << n); S++) {
		double p = 1; int x = 0;
		vector<int> v;
		for (int i = 0; i < n; i++) {
			double unko = (i == 0 || i == n - 1 ? P1 : P2);
			if (n == 1) unko = P0;
			if ((S >> i) & 1) {
				p *= 1 - unko;
				x++;
			}
			else {
				p *= unko;
				if (x) {
					v.push_back(x);
					x = 0;
				}
			}
		}
		if (x) v.push_back(x);
		double sum = 0;
		for (int j = 0; j < v.size(); j++)
			sum += f(v[j], k - 1, memo);
		ans += p * sum;
	}
	return memo[n][k] = ans;
}

int main() {
	int A; cin >> A;
	cin >> P0 >> P1 >> P2;
	P0 /= 100; P1 /= 100; P2 /= 100;
	vector<vector<double> > memo(15, vector<double>(80, -1));
	printf("%.10f\n", f(14, 80 - A, memo) * 2);
}
0