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

why WA???????????????????????????????????????

Posted by BJ051155 at 2007-04-27 15:14:19 on Problem 3154
#include <stdio.h>

int main(int argc, char* argv[])
{
	int n,m,i,j,k=0;
	char a[20];
	double d,fd,ld,pos,pos1;
	while(gets(a)&&scanf("%d%d",&n,&m)==2)
	{
		gets(a);
		gets(a);
		k++;
		j=0;
		pos1=d=0;
		fd=(float)10000/n;
		ld=(float)10000/(n+m);
		for(i=1;i<n;i++)
		{
			pos=i*fd;
			while(pos1<pos)
			{
				j++;
				pos1=j*ld;
			}
			d+=(pos1-pos>=pos-pos1+ld)?(pos-pos1+ld):(pos1-pos);
		}
		printf("sample output #%d\n",k);
		int t=d;
		if(t==d)
			printf("%d.0\n",t);
		else
			printf("%.4lf\n",d);
		printf("\n");
	}
	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