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:ACM06060 at 2007-01-29 09:45:56 可以不用副点运算,用乘法模拟 贴一点AC部分代码 LL64 adda = a + 1; const LL64 base = (LL64)(pow(10, L) + 0.1); const LL64 pow2 = base * base; LL64 maxa = adda * adda, amax = 2 * adda * base; LL64 mina = (adda - 1) * a, amin = 2 * base * a; LL64 La = 1, Lm = 0; for (k = 1; ; k++){ maxa += amax; mina += amin; if (mina >= pow2 || maxa >= pow2){ La += mina / pow2; Lm += maxa / pow2; if (La < Lm || (La == Lm && base != adda)){ La += (LL64)k * k; break; } maxa %= pow2; mina %= pow2; } } printf("%I64d\n", La); Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator