結果

問題 No.162 8020運動
ユーザー sugim48sugim48
提出日時 2015-03-05 23:59:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4,378 ms / 5,000 ms
コード長 1,658 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 97,720 KB
実行使用メモリ 200,068 KB
最終ジャッジ日時 2023-09-06 15:20:23
合計ジャッジ時間 100,207 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,827 ms
199,844 KB
testcase_01 AC 2,967 ms
199,844 KB
testcase_02 AC 3,595 ms
200,036 KB
testcase_03 AC 4,217 ms
200,032 KB
testcase_04 AC 4,205 ms
199,844 KB
testcase_05 AC 4,221 ms
200,040 KB
testcase_06 AC 4,222 ms
199,844 KB
testcase_07 AC 4,230 ms
199,892 KB
testcase_08 AC 4,240 ms
199,848 KB
testcase_09 AC 1,830 ms
199,896 KB
testcase_10 AC 3,602 ms
199,844 KB
testcase_11 AC 3,025 ms
200,036 KB
testcase_12 AC 2,339 ms
199,908 KB
testcase_13 AC 4,378 ms
199,844 KB
testcase_14 AC 1,954 ms
200,036 KB
testcase_15 AC 1,956 ms
200,056 KB
testcase_16 AC 2,452 ms
200,052 KB
testcase_17 AC 2,074 ms
200,032 KB
testcase_18 AC 4,094 ms
199,904 KB
testcase_19 AC 3,471 ms
200,052 KB
testcase_20 AC 3,739 ms
199,844 KB
testcase_21 AC 3,693 ms
199,900 KB
testcase_22 AC 3,572 ms
200,032 KB
testcase_23 AC 3,685 ms
199,840 KB
testcase_24 AC 3,617 ms
200,068 KB
testcase_25 AC 3,853 ms
200,060 KB
testcase_26 AC 1,852 ms
199,792 KB
testcase_27 AC 3,106 ms
199,900 KB
testcase_28 AC 4,104 ms
199,844 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;

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