标签:
样例输入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<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 #include<queue> 7 #include<cstdlib> 8 #include<iomanip> 9 #include<cassert> 10 #include<climits> 11 #define maxn 10001 12 #define F(i,j,k) for(int i=j;i<=k;i++) 13 #define M(a,b) memset(a,b,sizeof(a)) 14 #define FF(i,j,k) for(int i=j;i>=k;i--) 15 #define inf 0x7fffffff 16 #define q 23333333333333333 17 using namespace std; 18 int read(){ 19 int x=0,f=1;char ch=getchar(); 20 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} 21 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} 22 return x*f; 23 } 24 int a[210],n,m,t,i,j,k; 25 double p[210],f[201][201][401],ans; 26 int main() 27 { 28 std::ios::sync_with_stdio(false); 29 // freopen("data.in","r",stdin); 30 // freopen("data.out","w",stdout); 31 cin>>n>>m>>t; 32 F(i,1,n) cin>>p[i],p[i]/=100; 33 F(i,1,n) cin>>a[i]; 34 if(t>n) t=n; 35 f[0][0][t+200]=1; 36 for(i=0;i<n;i++) 37 for(j=0;j<=n;j++) 38 for(k=-n;k<=n;k++) 39 if(a[i+1]==-1){ 40 f[i+1][j][k+200]+=f[i][j][k+200]*(1-p[i+1]); 41 f[i+1][j+1][k-1+200]+=f[i][j][k+200]*p[i+1]; 42 } 43 else{ 44 f[i+1][j+1][min(k+a[i+1],n)+200]+=f[i][j][k+200]*p[i+1]; 45 f[i+1][j][k+200]+=f[i][j][k+200]*(1-p[i+1]); 46 } 47 for(j=m;j<=n;j++) 48 for(k=0;k<=n;k++) 49 ans+=f[n][j][k+200]; 50 cout<<setiosflags(ios::fixed)<<setprecision(6)<<ans<<endl; 51 return 0; 52 }
标签:
原文地址:http://www.cnblogs.com/SBSOI/p/5634564.html