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

改进乘法复杂度的常数因子(乘法计算减少一半),还是无法过, 期待指点,,,

Posted by WMM_205 at 2007-12-03 16:50:23 on Problem 3324
In Reply To:据我搜索资料,发现最快的就是FFT了。 也许你的算法效率问题不在那儿~ 呵呵~~纯属猜测。 期待牛人回复~~ Posted by:411465294 at 2007-12-02 22:44:00
int myMulti(unsigned long *a, int len_a, 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<<1));
	for(i=0; i<len_a; i++)
	{
		step=0;
		h=(__int64)a[i]*a[i]+c[i<<1]+step;
		unsigned long temp=(p_h[0]>>base);
		step=(p_h[1]<<(32-base))+temp;
		c[i<<1]=(p_h[0]-(temp<<base));   
				
		for(j=i+1; j<len_a; j++)
		{
			h=(__int64)a[i]*(a[j]<<1)+c[i+j]+step;
			temp=(p_h[0]>>base);
			step=(p_h[1]<<(32-base))+temp;
			c[i+j]=(p_h[0]-(temp<<base));
		}
		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