分解质因数(试除法)
- decompose
点击查看代码
void decompose(int x) {
for(int i = 2; i*i <= x; i++) {
while(x%i == 0) {
x /= i;
fact[i]++;
}
}
if(x > 1) fact[x]++;
}
void decompose(int x) {
for(int i = 2; i*i <= x; i++) {
while(x%i == 0) {
x /= i;
fact[i]++;
}
}
if(x > 1) fact[x]++;
}