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

为什么出现死循环的概率那么高?

Posted by sunmoonstar_love at 2005-08-17 23:33:27
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:
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