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

如何用C++通过这题啊,如果用2^32进制就没有办法用FFT了。

Posted by yygy at 2014-08-06 21:26:06 on Problem 3324
In Reply To:求教:我的乘法基为2^32,直接相乘,太耗时了,该如何优化? Posted by:WMM_205 at 2007-12-02 14:32:38
> 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