Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
可能是你程序中精度有点问题,uva和这边g++版本不同,出来结果有小差异In Reply To:Why I got WA here? Posted by:noskill at 2005-04-21 10:33:06 你调调精度试试看 或者改为vc提交就能过了(当然最好是g++也能过) > It was Accepted in uva,but why WA here? > > #include<stdio.h> > #include<math.h> > int main() > { > int a,b,i,j,m=0; > double r,t,t1,t2,near; > while(scanf("%d %d",&a,&b)==2) > { > if(m)printf("\n"); > r=(double)a/b; > j=1;near=r; > i=(int)(r); > t1=(double)i;t2=(double)(i+1); > if(fabs(t1-near)<fabs(t2-near)) > {printf("%d/%d\n",i,j);near=fabs(t1-r);} > else > {printf("%d/%d\n",i+1,j);near=fabs(t2-r);} > j++; > while(j<=b) > { > i=(int)(r*j); > t1=(double)i/j;t2=(double)(i+1)/j; > if(fabs(t1-near)<fabs(t2-near)&&fabs(t1-r)<near) > {printf("%d/%d\n",i,j);near=fabs(t1-r);} > else if(fabs(t2-r)<near) > {printf("%d/%d\n",i+1,j);near=fabs(t2-r);} > j++; > } > m++; > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator