The number of divisors(约数) about Humble Numbers

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define maxn 1000005
typedef long long ll;

int p[4]={2,3,5,7};
ll a[4];
bool book[1000005];
void fun(ll n)
{
for(int i=0;i<=3;i++)
{
while((n%p[i]==0) && (n!=0))
{
n=n/p[i];
a[i]++;
}
}
}
int main ()
{
ll n;

while(scanf("%lld",&n)!=EOF)
{
ll sum=1;
memset(a,0,sizeof(a));
if(n==0)
break;
//memset(book,true,sizeof(book));
//memset(a,0,sizeof(a));
if(n==1)
sum=1;
else if(n==2||n==3)
sum=2;
else
{
fun(n);
for(int i=0;i<=3;i++)
{
if(a[i]!=0)
sum=sum*(a[i]+1);
}
}
cout<<sum<<endl;
}
return 0;
}

猜你喜欢

转载自www.cnblogs.com/huanya/p/9374615.html