Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求教:我的乘法基为2^32,直接相乘,太耗时了,该如何优化?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator