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 |
求1/n的时候出错了求1/n的时候出错了,这样求,1/n永远是0。 题目求得1/n是高精度的小数,直接sum+=1/n,sum是不会变的。 这样求就可以了: double a=0; while(1){ a=a+0.000001; if((1-a*n)<0.000001) //a=1/n,a是要求的数 return a; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator