| ||||||||||
| 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 | |||||||||
Re:各位大牛小牛,帮忙看下一个很诡异的问题In Reply To:各位大牛小牛,帮忙看下一个很诡异的问题 Posted by:drift_ice at 2007-04-17 21:03:06 > #include <math.h>
> main()
> {
> int ax,bx,temp;
> int k,wantedax;
> while(scanf("%d%d",&ax,&bx)==2){
>
> if(ax>bx){
> temp = bx;
> bx = ax;
> ax = temp;
> }
>
> k = bx - ax;
> wantedax = (floor)(k*(1.0+sqrt(5))/2.0 ); //如果换成 k*1.6180340 就不行
> if(ax==wantedax)printf("%d\n",0);
> else printf("%d\n",1);
>
> }
> }
>
> 为什么这样可以通过,而如果改成注释的值就是WA呢?想不明白啊
//应该是精度的问题呀.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator