結果

問題 No.162 8020運動
ユーザー sugim48sugim48
提出日時 2015-03-05 23:54:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,623 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 88,136 KB
実行使用メモリ 307,640 KB
最終ジャッジ日時 2023-09-06 15:14:13
合計ジャッジ時間 16,462 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 <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;

int main() {
	int A; cin >> A;
	vector<double> p(3); cin >> p[0] >> p[1] >> p[2];
	p[0] /= 100; p[1] /= 100; p[2] /= 100;
	vector<map<int, double> > a(1 << 14);
	for (int S = 0; S < (1 << 14); S++) {
		int T = S;
		do {
			a[S][T] = 1;
			for (int i = 0; i < 14; i++) {
				if (!((S >> i) & 1)) continue;
				int cnt = 0;
				if (i - 1 >= 0 && (S >> (i - 1)) & 1) cnt++;
				if (i + 1 < 14 && (S >> (i + 1)) & 1) cnt++;
				if ((T >> i) & 1) a[S][T] *= (1 - p[cnt]);
				else a[S][T] *= p[cnt];
			}
			T = (T - 1) & S;
		} while (T != S);
	}
	vector<double> dp(1 << 14);
	dp[(1 << 14) - 1] = 1;
	for (; A < 80; A++) {
		vector<double> _dp(1 << 14);
		for (int S = 0; S < (1 << 14); S++) {
			int T = S;
			do {
				_dp[T] += dp[S] * a[S][T];
				T = (T - 1) & S;
			} while (T != S);
		}
		dp = _dp;
	}
	double ans = 0;
	for (int S = 0; S < (1 << 14); S++) {
		int cnt = 0;
		for (int i = 0; i < 14; i++)
			if ((S >> i) & 1) cnt++;
		ans += dp[S] * cnt;
	}
	printf("%.10f\n", ans * 2);
}
0