| ||||||||||
| 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 | |||||||||
再贴个fermatIn Reply To:这个pollard_rho把我搞无语了 Posted by:sunmoonstar_love at 2005-08-17 23:25:51 int fermat(int n)
{
int result;
do {
int x = (int)ceil(sqrt(0.0+n));
int y = x*x - n;
while(!issqrt(y)){
y = y + 2*x + 1;
x += 1;
}
// This method could easely
// return the other prime too
// (x-sqrt(y));
result = int(x+sqrt(0.0+y)+0.5);
} while(result == n);
return result;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator