Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

I don't know i got WA ... please help 2151

Posted by Algorithm_genius at 2009-12-30 01:21:17 on Problem 2151 and last updated at 2009-12-30 01:38:41
#include <stdio.h>
int n,t,m,i,j,k;
double a[1001][31],p[1001][31];
int main(){
	while(scanf("%d%d%d",&m,&t,&n),n){
		for(i=0;i<t;i++){
			for(k=0;k<=m;k++) p[i][k]=0;
			p[i][0]=1;
			for(j=0;j<m;j++){
				scanf("%lf",&a[i][j]);
				for(k=j;k>=-1;k--){
					p[i][k+1]=p[i][k+1]*(1-a[i][j]);
					if(k>=0) p[i][k+1]+=p[i][k]*a[i][j];
				}
			}
		}
		double all=1,ex=1;
		for(i=0;i<t;i++){
			double sum=0;
			for(j=1;j<=n;j++) sum+=p[i][j];
			all*=sum; ex*=(sum-p[i][n]);
		}
		printf("%.3lf\n",all-ex);
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator