2009-01-22
SRM359 Div1 Easy: DriveFailures
- SRM前のウォーミングアップ(1)
- 簡単...242.10points(5'09),Passed System Test
#define sz(a) int((a).size()) #define rep(var,n) for(int var=0;var<(n);var++) class DriveFailures { public: vector<double> failureChances(vector <double> failureProb) { int n=sz(failureProb);//1-15 vector<double> ans(n+1,0.0); ans[0]=1.0; rep(i,n){ vector<double> w(n+1,0.0); double r=failureProb[i]; rep(j,n){ w[j] +=ans[j]*(1.0-r); w[j+1] +=ans[j]*r; } rep(j,n+1) ans[j]=w[j]; } return ans; } };