<1> preparation algorithm [cpp] LL mul (LL a, LL B, LL p) {LL rn = 0, I; for (I = 1; I <= B; I <= 1, a = (a + a) % p) if (B & I) rn = (rn + a) % p; return rn ;} // product of two big numbers LL ksm (LL a, LL B, LL p) {LL rn = 1; for (; B; a = mul (, p), B> = 1) if (B & 1) rn = mul (rn, a, p); return rn ;} // In the computing model, the two large numbers multiply by LL gcd (LL a, LL B) {LL tmp; if (a <B) tmp = a, a = B, B = tmp; while (B) tmp = a % B, a = B, B = tmp; return a;} // calculate the maximum approximate number <2> Miller Robin prime number test can be in (0.25) ^ S determines the prime number at the error rate, which must be paid accordingly The time complexity of output (S * log n. The principle is based on two theorems: 1. If p is a prime number, 0 <a <p, then a ^ (p-1) 1_1 (mod p ). 2. For 0 <x <p, x ^ 2 then 1 (mod p), there are only two solutions: x = 1 and x = p-1. [Cpp] bool isprime (LL n) {if (n = 2) return true; if (n <2 |! (N & 1) return false; LL a, x, y, u = n-1; int t = 0; while (u & 1) = 0) t ++, u> = 1; for (I = 0; I <S; I ++) {a = rand () % (n-1) + 1; x = ksm (, u, n); for (int j = 1; j <= t; j ++) {y = mul (x, x, n ); if (y = 1 & x! = 1 & x! = N-1) return false; x = y;} if (x! = 1) return false;} return true;} <3> the complexity of Pollcard rock factor decomposition seems to be n ^ (1/4), which should be the fastest Algorithm for factorization. [Cpp] void ROV (LL n) {if (isprime (n) {list [++ top] = n; return;} LL a, x, y, z, p; while (true) {for (x = 1, y = 1, z = rand () + 1, p = 1; p = 1 ;) {www.2cto.com y = (mul (y, y, n) + z) % n; p = gcd (x-y + n) % n, n ); x = (mul (x, x, n) + z) % n; y = (mul (y, y, n) + z) % n ;} if (p = n) continue; Arg (p); Arg (n/p); return ;}} is the correctness clear, and complexity analysis-in short, it is very fast.