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:这道题有什么好的办法控制精度

Posted by hyb02 at 2007-01-31 21:23:16 on Problem 3175
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:
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