結果

問題 No.162 8020運動
ユーザー yuusti
提出日時 2015-03-13 02:54:35
言語 C++11
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,653 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-28 22:49:17
合計ジャッジ時間 2,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#ifdef _MSC_VER
#include <agents.h>
#endif
#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
double dp[20][20];
double p[3];
double rec(int n, int rem){
if (!n) return rem;
double &res = dp[n][rem];
if (res >= -.5) return res;
if (rem == 1) return res = (1 - p[0])*rec(n - 1, rem);
res = 0;
rep(i, 1 << rem){
double pp = 1;
rep(j, rem){
if (i >> j & 1) pp *= j == 0 || j == rem - 1 ? 1 - p[1] : 1 - p[2];
else pp *= j == 0 || j == rem - 1 ? p[1] : p[2];
}
double ex = 0;
int run = 0;
rep(j, rem){
if (i >> j & 1) ++run;
else ex += rec(n - 1, run), run = 0;
}
ex += rec(n - 1, run), run = 0;
res += pp*ex;
}
return res;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(20);
int n;
cin >> n;
n = 80 - n;
rep(i, 3) cin >> p[i];
rep(i, 3) p[i] /= 100;
rep(i, 20) rep(j, 20) dp[i][j] = -1;
cout << rec(n, 14) * 2 << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0