参考链接:https://blog.csdn.net/m0_38081836/article/details/78108166
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int pri[maxn],cnt=0;
bool book[maxn];
void Prime(){ ///快速筛素数表
memset(book,0,sizeof(book));
cnt=0;
book[0]=book[1]=1;
for(int i = 2; i<maxn; i++){
if(!book[i])
pri[cnt++]=i;
for(int j=0;j<cnt && pri[j]*i<maxn; j++){
book[i*pri[j]] = 1;
if(i % pri[j]==0)
break;
}
}
}
LL counts(LL num)///计算num的因子总数
{
LL s = 1;
/// num == 0 没有素数因子也就返回零就可以了
if(num == 0)
return 0;
LL tt = 0;
LL i = 0;
while(pri[i] < num && i < cnt)/// 条件素数因子应该小于num,并且在我们所打表的范围内
{
tt = 0;///计数器用来记录num的素数因子的个数
if(num % pri[i] == 0)/// 满足条件
{
while(num % pri[i] == 0)///循环直到不能被当前的素数整除
{
num /= pri[i];
tt++;
}
}
s *= tt + 1;
i++;
}
if(num > 1)
{
s *= 1 + 1;
}
return s;
}
int main()
{
cnt=0;
Prime(); ///预处理
int a;
while(~scanf("%d",&a)){
printf("%lld\n",counts(a));
}
return 0;
}