結果

問題 No.162 8020運動
ユーザー parukiparuki
提出日時 2016-09-06 00:37:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 811 ms / 5,000 ms
コード長 1,989 bytes
コンパイル時間 1,683 ms
コンパイル使用メモリ 172,852 KB
実行使用メモリ 63,688 KB
最終ジャッジ日時 2024-04-27 16:42:50
合計ジャッジ時間 24,785 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 635 ms
62,920 KB
testcase_01 AC 721 ms
63,680 KB
testcase_02 AC 763 ms
63,232 KB
testcase_03 AC 805 ms
63,688 KB
testcase_04 AC 811 ms
63,688 KB
testcase_05 AC 806 ms
63,688 KB
testcase_06 AC 808 ms
63,688 KB
testcase_07 AC 804 ms
63,688 KB
testcase_08 AC 808 ms
63,684 KB
testcase_09 AC 636 ms
62,796 KB
testcase_10 AC 760 ms
62,976 KB
testcase_11 AC 716 ms
62,464 KB
testcase_12 AC 670 ms
61,952 KB
testcase_13 AC 805 ms
63,616 KB
testcase_14 AC 642 ms
61,440 KB
testcase_15 AC 643 ms
61,312 KB
testcase_16 AC 678 ms
63,304 KB
testcase_17 AC 653 ms
63,048 KB
testcase_18 AC 796 ms
63,528 KB
testcase_19 AC 754 ms
62,976 KB
testcase_20 AC 769 ms
63,560 KB
testcase_21 AC 771 ms
63,232 KB
testcase_22 AC 786 ms
63,560 KB
testcase_23 AC 769 ms
63,104 KB
testcase_24 AC 761 ms
63,232 KB
testcase_25 AC 780 ms
63,488 KB
testcase_26 AC 639 ms
61,440 KB
testcase_27 AC 727 ms
63,556 KB
testcase_28 AC 798 ms
63,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int bitcnt(int n){
    int res = 0;
    while(n){
        if(n&1) ++res;
        n>>=1;
    }
    return res;
}

const int N = 14;
vi to[1 << N];
vector<double> pr[1 << N];
int bs[1 << N];
double dp[21][1 << N];

int main(){
    int A;
    cin >> A;
    int Y = 80 - A;
    double P0, P1, P2;
    cin >> P0 >> P1 >> P2;
    P0 *= 0.01;
    P1 *= 0.01;
    P2 *= 0.01;

    rep(S, 1 << N){
        bitset<N> b(S);
        FOR(nS, S, 1 << N)if((S&nS)==S){

            bitset<N> nb(nS);
            double p = 1;
            rep(i, N){
                if(b[i])continue;
                if((i == 0||b[i-1]) && (i==N-1 || b[i+1])){
                    if(nb[i])p *= P0;
                    else p *= 1.00 - P0;
                } else if((i == 0 || b[i - 1]) || (i == N - 1 || b[i + 1])){
                    if(nb[i])p *= P1;
                    else p *= 1.00 - P1;
                } else{
                    if(nb[i])p *= P2;
                    else p *= 1.00 - P2;
                }
            }
            to[S].push_back(nS);
            pr[S].push_back(p);
        }
        bs[S] = bitcnt(S);
    }

    dp[0][0] = 1;
    rep(y, Y)rep(S, 1 << N){
        rep(i, sz(to[S])){
            int nS = to[S][i];
            double p = pr[S][i];
            dp[y + 1][nS] += dp[y][S] * p;
        }
    }

    double hoge = 0;
    rep(i, 1 << N)hoge+=dp[Y][i];

    double ans = 0;
    rep(S, 1 << N)ans += (N-bitcnt(S))*dp[Y][S];
    cout << setprecision(20) << ans*2 << endl;
}
0