| ||||||||||
| 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 | |||||||||
为什么出现死循环的概率那么高?In Reply To:这个pollard_rho把我搞无语了 Posted by:sunmoonstar_love at 2005-08-17 23:25:51 > unsigned long pollard_rho(unsigned long n)
> {
> unsigned long gcd_result;
>
> do {
> unsigned long x = true_random(n);
> unsigned long a = 1;
> unsigned long y; // 注意
>
> x = (x*x + a) % n;
> y = (y*y + a) % n; // 注意 unsigned long y;
>
> gcd_result = gcd(x-y, n);
>
> while(gcd_result == 1) {
> x = (x*x + a) % n;
>
> y = (y*y + a) % n;
> y = (y*y + a) % n;
>
> gcd_result = gcd(x-y, n);
> }
> } while(gcd_result == n);
>
> return gcd_result;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator