求因子个数
下面放个求因子个数的方法
#define ll long long
ll calc(ll x){//求因子个数
if(cnt.count(x)) return cnt[x];
ll ans=1;
for(ll i=2;i*i<=x;++i){
if(x%i==0){
ll c=0;
while(x%i==0){
++c;
x/=i;
}
ans*=c+1;
}
}
if(x!=1) ans*=2;
return ans;
}
本文来自博客园,作者:Qiansui,转载请注明原文链接:https://www.cnblogs.com/Qiansui/p/17529743.html