Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于C代码和Pollard的问题';对数的s-rho算法_C_Discrete Mathematics_Logarithm - Fatal编程技术网

关于C代码和Pollard的问题';对数的s-rho算法

关于C代码和Pollard的问题';对数的s-rho算法,c,discrete-mathematics,logarithm,C,Discrete Mathematics,Logarithm,这段代码是由pollard的rho对数算法(来自wiki)的C编写的。在这段代码中,如果我输入alpha=2,beta=5,N=1019,它必须返回a=681,b=378,a=301,b=426和X=1019。但是我运行它,我只得到正确的X=1019,我得到(a,b,a,b)=(672367445706)。你知道问题出在哪里吗 #包括 #包括 intα,β,N; void xab(int*x,int*a,int*b) { 开关(*x%3){ 案例0:*x=((*x)*(*x))%N;*a=((

这段代码是由pollard的rho对数算法(来自wiki)的C编写的。在这段代码中,如果我输入alpha=2,beta=5,N=1019,它必须返回a=681,b=378,a=301,b=426和X=1019。但是我运行它,我只得到正确的X=1019,我得到(a,b,a,b)=(672367445706)。你知道问题出在哪里吗

#包括
#包括
intα,β,N;
void xab(int*x,int*a,int*b)
{
开关(*x%3){
案例0:*x=((*x)*(*x))%N;*a=((*a)*2)%N;*b=((*b)*2)%N;中断;
案例1:*x=(alpha*(*x))%N;*a=((*a)+1)%N;中断;
案例2:*x=(β*(*x))%N;*b=((*b)+1)%N;中断;
} 
}  
内部主(空)
{    
整数x=1;整数a=0;整数b=0;
整数X=1;整数A=0;整数B=0;
int i;
scanf(“%d%d%d”、&alpha、&beta、&N);

对于(i=1;i您没有正确复制
new_xab
函数。请注意
new_xab
函数同时使用
N
N
,其中
N=1019
N=1018

case 0: x = x*x     % N;  a =  a*2  % n;  b =  b*2  % n;  break;
case 1: x = x*alpha % N;  a = (a+1) % n;                  break;
case 2: x = x*beta  % N;                  b = (b+1) % n;  break;
case 0: x = x*x     % N;  a =  a*2  % n;  b =  b*2  % n;  break;
case 1: x = x*alpha % N;  a = (a+1) % n;                  break;
case 2: x = x*beta  % N;                  b = (b+1) % n;  break;