摘要:
欧拉函数:φ(n)即在1~n中与n互质的数的个数φ(1) = 1, φ(2) = 1, φ(3) = 2,φ(4) = 2,φ(5) = 4,φ(6) = 2(即1、5) 对于一个数N肯定等于它的质因子的指数和:N = p1^φ1 + p2^φ2 + ……+pk^φk。 那么求该数的欧拉函数等于:φ 阅读全文
摘要:
试除法求约数: #include <iostream> #include <algorithm> #include <vector> using namespace std; int n; vector<int> get_divisors(int x) { vector<int> res; for( 阅读全文
摘要:
埃氏筛法: #include <iostream> using namespace std; const int N = 1e6; int n, cnt, primes[N]; bool st[N]; void get_primes(int n) { //时间复杂度:n/2 + n / 3 + .. 阅读全文