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

求教:我的乘法基为2^32,直接相乘,太耗时了,该如何优化?

Posted by WMM_205 at 2007-12-02 14:32:38 on Problem 3324
int myMulti(unsigned long *a,int len_a,unsigned long *b, int len_b,unsigned long *c)
{
	int i=0, j=0;
	unsigned long step=0;
	__int64 h=0;
	unsigned long *p_h =(unsigned long *)&h;
	memset(c, 0, sizeof(unsigned long)*(len_a+len_b));
	for(i=0; i<len_b; i++)
	{
		step=0;
		for(j=0; j<len_a; j++)
		{
			h=(__int64)a[j]*b[i]+c[i+j]+step;
			c[i+j]=p_h[0];   
			step=p_h[1];     
		}
		c[(j++)+i]=step;
	}
	return i+j-1;
}

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