欧拉筛分解质因子板子
int p[N], pe[N], primes[N], cnt; void init() { for (int i = 2; i < N; i++ ) { if(!p[i]) p[i] = i, pe[i] = i, primes[++ cnt] = i; for (int j = 1; j <= cnt && i * primes[j] < N; j++ ){ p[i * primes[j]] = primes[j]; if(p[i] == primes[j]) { pe[i * primes[j]] = pe[i] * primes[j]; break; } else pe[i * primes[j]] = primes[j]; } } } vector<int> v; while(t > 1) { v.push_back(p[t]); int pp = p[t]; while(t % pp == 0) t /= pp;//如果需要统计质因子个数在这个操作下可以开map或者桶来统计 }