标签:prim oal ret class pre 质因子分解 log 分解 ack
LL Pollard_Rho(LL n, LL c) { LL x, y, d; LL i = 1, k = 2; x = y = rand() % n; do { i++; d = gcd(n + y - x, n); if(d > 1 && d < n) return d; if(i == k) { y = x; k <<= 1; } x = (mul_mod(x, x, n) + n - c) % n; } while(y != x); return n; } void rhoAll(LL n) { if(n <= 1) return; if(isPrime(n)) { fac.push_back(n); return; } LL t = n; while(t >= n) t = Pollard_Rho(n, rand() % (n-1) + 1); rhoAll(t); rhoAll(n/t); return; }
标签:prim oal ret class pre 质因子分解 log 分解 ack
原文地址:http://www.cnblogs.com/sapphirebitter/p/7371855.html