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?

Posted by 00130004 at 2004-05-16 10:31:22 on Problem 1654
In Reply To:郁闷呀,为什么wa? Posted by:yipeng at 2004-05-16 10:08:49
> #include "stdio.h"
> #include "math.h"
> void main(){
> 	long t,i,j,k,x[5],y[5];
> 	double s1;
> 	char c;
> 	long s;
         ~~~~~~~精度不够,要用__int64
> 	scanf("%d",&t);
> 	for(i=1;i<=t;i++){
>         s1=0;
> 		s=0;
> 		for(j=0;j<5;j++)
> 			x[j]=y[j]=0;
> 		scanf("%c",&c);
> 		while(c==' '||c=='\n')
> 			scanf("%c",&c);
> 		j=0;
> 		while(c!='5'){
> 			k=j;
> 			j=(j+1)%5;
> 			if(c=='1'){
>                 x[j]=x[k]-1;
> 				y[j]=y[k]-1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='2'){
>                 x[j]=x[k];
> 				y[j]=y[k]-1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='3'){
>                 x[j]=x[k]+1;
> 				y[j]=y[k]-1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='4'){
>                 x[j]=x[k]-1;
> 				y[j]=y[k];
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='6'){
>                 x[j]=x[k]+1;
> 				y[j]=y[k];
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='7'){
>                 x[j]=x[k]-1;
> 				y[j]=y[k]+1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='8'){
>                 x[j]=x[k];
> 				y[j]=y[k]+1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 			if(c=='9'){
>                 x[j]=x[k]+1;
> 				y[j]=y[k]+1;
> 				s1=s1+(double)(x[k]*y[j]-x[j]*y[k])/2;
> 				scanf("%c",&c);
> 				continue;
> 			}
> 		}
> 		s=(long)s1;
> 		if(fabs(s1-s)<0.00001){
> 			s=abs(s);
> 			printf("%d\n",s);
> 		}
> 		else{
> 			s1=fabs(s1);
> 			printf("%.1f\n",s1);
> 		}
> 	}
> }

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