比赛 难度范围:提高至省选 评测结果 WWWWWWWWTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
题目名称 傻叉小明打字 最终得分 0
用户昵称 HouJikan 运行时间 12.083 s
代码语言 C++ 内存使用 0.38 MiB
提交时间 2014-10-16 19:59:39
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
//==============struct declaration==============
struct adj{
  int to,dist;
  adj (int to=0,int dist=0):to(to),dist(dist){}
};
//==============var declaration=================
const int MAXN=3010;
double w[MAXN],p[MAXN];
int n,t;
double f[MAXN];
//==============function declaration============

//==============main code=======================
int main()
{  
  string FileName="sb_xiaoming";//程序名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
  scanf("%d%d",&n,&t);
  p[0]=1;
  For(i,1,n){
    scanf("%lf",w+i);
    p[i]=p[i-1]*(1-w[i]);
  }
  f[n]=1/(1-w[n]);
  for(int i=n-1;i>=1;i--){
    double minp=1000000000;
    for(int k=i+1;k<=n;k++){
      double res=k-i+1+t;
      for(int j=k+1;j<=n;j++)
        res+=p[j]/p[i]*w[j]*(f[j]+k-j+1);
      if (res<minp)
        minp=res; 
    }
    f[i]=1/(1-w[i])+minp;
  }
  printf("%.6lf\n",f[1]);
  return 0;
}
//================fuction code====================