Probability expect six Training

analysis:

Count two steps

A: of Li i represents a second continuous expectations

** Li = (Li + 1) * ai% **

Two: Fi represents a desired value generated phantom seconds before i

** F [i] = F [i-1] + ((L [i-1] +1) ^ 2 ^ - (L [i-1]) ^ 2 ^) * and **%

code:

#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)

using namespace std;

const int maxn=1e6+2;
int n,a[maxn];
double f[maxn],L[maxn];

double sqr(double x){
    return x*x;
}
int main()
{
    scanf("%d",&n);
    fo(i,1,n) {
        scanf("%d",&a[i]);
        L[i]=(L[i-1]+1)*(double)a[i]/(double)100;
        f[i]=f[i-1]+(sqr(L[i-1]+1)-sqr(L[i-1]))*a[i]/(double)100;   
    }
    printf("%.1lf",f[n]);
}

Guess you like

Origin www.cnblogs.com/wzxbeliever/p/11788514.html