标签:依次 app cst ble style 必须 get argv str
样例输入1
3 1 0
10 20 30
-1 -1 2
样例输入2
5 1 2
36 44 13 83 63
-1 2 -1 2 1
样例输出1
0.300000
样例输出2
0.980387
1 #include <algorithm> 2 #include <cstdio> 3 4 #define min(a,b) (a<b?a:b) 5 6 inline void read(int &x) 7 { 8 x=0; register char ch=getchar(); register bool _=0; 9 for(; ch>‘9‘||ch<‘0‘; ch=getchar()) if(ch==‘-‘) _=1; 10 for(; ch>=‘0‘&&ch<=‘9‘; ch=getchar()) x=x*10+ch-‘0‘; 11 x=_ ?((~x)+1) :x; 12 } 13 14 const int N(233); 15 16 double f[N][N][N]; 17 int n,L,K; 18 19 struct Node { 20 int a; double p; 21 bool operator < (const Node&x) const { return a>x.a; } 22 }th[N]; 23 24 int Presist() 25 { 26 read(n),read(L),read(K); 27 for(int i=1; i<=n; ++i) 28 scanf("%lf",&th[i].p),th[i].p/=100; 29 for(int i=1; i<=n; ++i) read(th[i].a); 30 std:: sort(th+1,th+n+1); 31 f[0][0][min(n,K)]=1; 32 for(int i=1; i<=n; ++i) 33 for(int j=0; j<i; ++j) 34 for(int k=0; k<=n; ++k) 35 { 36 f[i][j][k]+=f[i-1][j][k]*(1-th[i].p); 37 int tmp=min(n,k+th[i].a); 38 if(tmp<0) continue; 39 f[i][j+1][tmp]+=f[i-1][j][k]*th[i].p; 40 } 41 double ans=0.0; 42 for(int i=L; i<=n; ++i) 43 for(int j=0; j<=n; ++j) 44 ans+= f[n][i][j]; 45 printf("%.6lf\n",ans); 46 return 0; 47 } 48 49 int Aptal=Presist(); 50 int main(int argc,char**argv){;}
标签:依次 app cst ble style 必须 get argv str
原文地址:http://www.cnblogs.com/Shy-key/p/7859035.html