???Henu ACM Round#15 D???Ilya and Escalator

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了???Henu ACM Round#15 D???Ilya and Escalator相关的知识,希望对你有一定的参考价值。

?????????local   precision   its   esc   color   using   ??????   round   down   

???????????? ????????????,?????????:)
????????????


?????????????????????

????????????


??????DP;
???f[i][j]?????????i???????????????,j????????????????????????????????????
??????????????????i-1??????????????????????????????????????????
i-1???????????????????????????->f[i][j]+=f[i-1][j-1]p
i-1??????????????????->
????????????n?????????,f[i][j] += f[i-1][j]
????????????n??????(j<n) f[i][j]+=f[i-1][j]
(1-p)
??????????????????\(???_1^nf[t][i]*i\)

????????????

#include <bits/stdc++.h>
using namespace std;

const int N = 2000+10;

double f[N][N];
//f[i][j]????i??,j???????????
int n;double p;int t;

int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    #ifdef LOCAL_DEFINE
        freopen("rush.txt","r",stdin);
    #endif
    cin >> n >> p >> t;
    f[0][0] = 1;
    for (int i = 1;i <= t;i++)
        for (int j = 0;j <= n;j++){
            if (j==n){
                f[i][j] += f[i-1][j];
            }else
                f[i][j] += f[i-1][j]*(1-p);
            if (j>0){
                f[i][j] += f[i-1][j-1]*p;
            }
        }

    double ans = 0;
    for (int i = 0;i <= n;i++){
        ans+=f[t][i]*i;
    }
    cout <<fixed<<setprecision(10)<< ans << endl;
    return 0;
}

以上是关于???Henu ACM Round#15 D???Ilya and Escalator的主要内容,如果未能解决你的问题,请参考以下文章

Henu ACM Round#15 A A and B and Chess

Henu ACM Round#16 A Bear and Game

Henu ACM Round#15 BA and B and Compilation Errors

Henu ACM Round#19 D Points on Line

Henu ACM Round#15 C A and B and Team Training

Henu ACM Round#15 E A and B and Lecture Rooms