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 |
也没什么要改的,最好不要让c==0或2In Reply To:帮我看看pollard怎么改进,和算法导论的,实用算法分析的差不多 Posted by:sunmoonstar_love at 2005-07-01 23:00:02 > llong pollard(llong n) > {//返回 n 的一个质因子 > srand(rand()+n); > llong i,k,d,c,x,y; > i = 1; k = 2; > y = x = abs(rand()%(n-1))+1; > c = abs(rand()%(n-1))+1; > do > { > i++; > d = GCD(n+y-x,n); > if(d>1&&d<n) > return d; > if(i==k) > { > y = x; > k *= 2; > } > // x = ((x%n)*x)%n - c + n; > x = mul_mod(x,x,n) - c + n; > // c = abs(rand()%(n-1))+1; > }while(y!=x); > return n; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator