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 Loonlie at 2007-06-02 07:57:26 on Problem 3199
In Reply To:Re:高精度 Posted by:gemenhao at 2007-02-08 23:35:02
> 考虑到数据比较小,可以不用高精度,呵呵
> int main()
> {
> 	int N, D;
> 	double maxn = pow(2.0, 62.5);
> 	while (scanf("%d %d", &N, &D) && (N != 0 || D != 0)){
> 		double max = pow(N, D);
> 		if (max < maxn){
> 			printf("%I64d\n", pown(N, D));
> 			continue;
> 		}
> 		__int64 a1 = pown(N, D / 2);
> 		__int64 a2 = pown(N, D - D / 2);
> 		__int64 a1h = a1 / base, a1l = a1 % base;
> 		__int64 a2h = a2 / base, a2l = a2 % base;
> 		__int64 low = a1l * a2l;
> 		__int64 hih = a1h * a2h * base + a1h * a2l + a2h * a1l + low / base; 
> 		printf("%I64d", hih);
> 		printf("%09I64d\n", low % base);
> 	}
> 	return 0;
> }

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