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

Re:WA了无数次,终于搞懂错在哪了,不是double的问题,加了几句后就AC了

Posted by sunflowwer at 2006-11-01 18:16:59 on Problem 2537
In Reply To:WA了无数次,终于搞懂错在哪了,不是double的问题,加了几句后就AC了 Posted by:x1e398u at 2005-11-06 10:44:50
为什么你的代码还是WA?
> #include <iostream.H>
> #include <math.h>
> 
> int main()
> {
> 	int k,n,i,j;
> 	double d[10][100];
> 	for(k=0;k<10;k++)
> 		d[k][0]=1;
> 	while(cin>>k>>n)
> 	{
> /*		if(k==0)
> 		{
> 			cout<<"100.00000\n";
> 			continue;
> 		}此段若不加就总WA,测试了一下,若不加则输入0,100后程序直接退出*/
> 		for(i=1;i<n;i++)
> 			for(j=0;j<=k;j++)
> 				if(!j) d[j][i]=d[j][i-1]+d[j+1][i-1];
> 				else if(j==k) d[j][i]=d[j][i-1]+d[j-1][i-1];
> 				else d[j][i]=d[j-1][i-1]+d[j][i-1]+d[j+1][i-1];
> 		double sum=0;
> 		for(i=0;i<=k;i++)
> 			sum+=d[i][n-1];
> 		sum*=100;
> 		sum/=pow(k+1,n);
> 		cout.setf(ios::fixed);
> 		cout.precision(5);
> 		cout<<sum<<endl;
> 	}
> 	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