結果

問題 No.162 8020運動
ユーザー tubo28tubo28
提出日時 2015-03-06 00:19:12
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 2,370 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 159,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 09:47:25
合計ジャッジ時間 2,175 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 13 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
    template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

typedef vector<double> vd;
typedef vector<vd> vvd;

double dp_[20][30];
double & dp(int i, int j){
    return dp_[i][j+2];
}
double inv(double x){
    return 1-x;
}

int main(){
    int A;
    while(cin >> A){
        double p0,p1,p2;
        cin >> p0 >> p1 >> p2;
        p1/=100; p2/=100; p0/=100;

        int N = 14;
        memset(dp_,0,sizeof(dp_));
        int D = 80-A;
        rep(i,N) dp(0,i) = 1;
        dp(0,-1) = dp(0,N) = 0;
        rep(i,D){
            rep(j,N){
                // dp(i+1,j) *= dp(i,j);
                dp(i+1,j) += dp(i,j+1) * dp(i,j-1) * inv(p2);

                dp(i+1,j) += dp(i,j+1) * inv(dp(i,j-1)) * inv(p1);
                dp(i+1,j) += inv(dp(i,j+1)) * dp(i,j-1) * inv(p1);

                dp(i+1,j) += inv(dp(i,j+1)) * inv(dp(i,j-1)) * inv(p0);

                dp(i+1,j) *= dp(i,j);
            }
            // rep(j,N){
            //     cout << dp(i+1,j) << " ";
            // }
            // cout << endl;
        }
        double ans = 0;
        rep(i,N) ans += dp(D,i);
        ans += ans;
        printf("%lf\n",ans);
    }
}
0