终于懂了点Pollard_rho算法的原理
int pollard_rho(int n, int c)///c为自己设定的某值
{
int x, y, d, i = 1, k = 2;
x = rand() % (n - 1) + 1;
y = x;
while (true) {
++i;
x = (modular_multi(x, x, n) + c) % n;
d = gcd(y - x, n);
if (1 < d && d < n)
return d;
if (x == y)
return n;
if (i == k)
y = x, k <<= 1;
}
}
底下补个kuangbin牛分解质因数模板:http://www.cnblogs.com/kuangbin/archive/2012/08/19/2646396.html