不会不会,,,%%http://hzwer.com/5813.html
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<map> 5 #include<cmath> 6 #include<queue> 7 #define N 1000005 8 #define inf 1000000000 9 #define LL long long 10 using namespace std; 11 int n,m; 12 double ans,p1; 13 double f[5005][5005]; 14 double p[5005],tmp[5005]; 15 int t[5005]; 16 int main() 17 { 18 scanf("%d%d",&n,&m); 19 for (int i=1; i<=n; i++) 20 { 21 int x,y; scanf("%d %d",&x,&t[i]); 22 p[i]=(double)x/100; 23 } 24 f[1][0]=1; p[n+1]=0; t[n+1]=5000; 25 for (int i=1; i<=n+1; i++) 26 { 27 p1=pow(1-p[i],t[i]); 28 for (int j=0; j<=m; j++) tmp[j]=f[i][j]; 29 for (int j=0; j<=m; j++) 30 { 31 f[i][j+1]+=f[i][j]*(1-p[i]); 32 f[i+1][j+1]+=f[i][j]*p[i]; 33 if (j+t[i]<=m) 34 { 35 f[i][j+t[i]]-=tmp[j]*p1; 36 f[i+1][j+t[i]]+=tmp[j]*p1; 37 } 38 } 39 } 40 for (int i=1; i<=n+1; i++) ans+=f[i][m]*(i-1); 41 printf("%.10lf",ans); 42 return 0; 43 }