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

贴下我代码中的poll_rho函数,大牛帮我看下吧,过了1811,这里怎么也过不了。

Posted by amouse at 2007-11-05 20:55:19 on Problem 2447
__int64 poll_rho(__int64 n)
{
	int p=1;
	mod=n;
	while(p++)
	{
		srand(p);
		__int64 x=rand()%(n-2)+2;
		__int64 y=x;
		int k=0;
		int i=2;
		__int64 d=1;
		int time=0;
		while(time<50000)//防止出现死循环
		{
			time++;
			k++;
			x=(mulmod(x,x)-1)%mod;
			if(x>y)d=gcd2(x-y,n);
			else d=gcd2(y-x,n);
			if(d>1&&d<n)return d;
			else if(d>=n)return -1;
			if(k==i)
			{
				y=x;
				i=i<<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