Hatena::Grouptopcoder

naoya_t@topcoder RSSフィード

2009-01-22

SRM359 Div1 Easy: DriveFailures

| 00:34 | SRM359 Div1 Easy: DriveFailures - naoya_t@topcoder を含むブックマーク はてなブックマーク - SRM359 Div1 Easy: DriveFailures - naoya_t@topcoder SRM359 Div1 Easy: DriveFailures - naoya_t@topcoder のブックマークコメント

  • 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;
  }
};
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090122