//对n进行素因子分解 void findfac(long long n){ if(Miller_Rabin(n)){//素数 factor[tol++]=n; return; } long long p=n; while(p>=n)p=Pollard_rho(p,rand()%(n-1)+1); findfac(p); findfac(n/p); }
/* *大整数质因数分解 *ret存储n的所有质因子,c是任意一个数字 */ void factorize(ll n, int c, vector<ll> &ret) { if (n == 1) return ; if (Miller_Rabin(n)) { ret.push_back(n); return ; } ll p = n; while (p >= n) p = Pollard_rho(p, c--); factorize(p, c, ret); factorize(n/p, c, ret); }
//对n进行素因子分解 void findfac(LL n) { if(Miller_Rabin(n,20)==0)//素数 { factor[tol++]=n; return; } LL p=n; while(p>=n) p=Pollard_rho(p,rand()%(p-1)+1); findfac(p); findfac(n/p); }