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

又是一个莫名其妙的错误,将DP中的=改为先赋成零,然后+=就可以了,

Posted by pillar at 2006-09-10 13:32:55 on Problem 1322
In Reply To:WA得不行了,高手指点 Posted by:pillar at 2006-09-10 13:16:03
> #include <stdio.h>
> #include <string.h>
> double arr[1002][101];
> int main(){
> 	int c,m,n,i,j;
> 	while (scanf("%d",&c))
> 	{
> 		if (!c)		break;
> 		scanf("%d%d",&n,&m);
> 		memset(arr,0,sizeof(arr));
> 		
> 		if (m>c||m>n){	printf("0.000\n");	continue;	}
> 		
> 		if (n>1000)
> 		{
> 			if (n%2)	n = 1001;
> 			else		n = 1000;
> 		}
> 		
> 		arr[1][1] = 1;
> 		for (i=2;i<=n;++i)
> 		{
> 			for (j=0;j<=c;++j)
> 			{
> 				if (!j)
> 					arr[i][j] = arr[i-1][1]/c;
> 				else if (j==c)
> 					arr[i][j] = arr[i-1][c-1]/c;
> 				else arr[i][j] = arr[i-1][j-1]*(c-j+1)/c + arr[i-1][j+1]*(j+1)/c;
> 			}
> 		}
> 		printf("%.3lf\n",arr[n][m]);
> 	}
> 	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