HDU1492(数论)

题目大意:约数仅由2,3,5,7组合的数叫做humble number,如丑数列:1,2,3,4,5,6,7,8,9,10,12,14,15,16, 18, 20, 21, 24, 25, 27, ...

                    求一个humble number的约数的个数;

题目解析:先求出Humble number=2^a*3^b*5^c*7^d,然后结果为ans=(a+1)*(b+1)*(c+1)*(d+1);

错误分析:想得太多,导致了TEL;还有就是long long 要换成__int64;


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef __int64 ll;
int enu[4]={2,3,5,7};
ll n,n1;
int init()
{
    ll i,j;
    scanf("%I64d",&n);
    if(n==0)return 0;
    ll ans=1;
    for(i=0;i<4;i++)
    {
        n1=n,j=0;
        while(n1>0)
        {
            if(n1%enu[i]==0)
            {
                ++j,n1/=enu[i];
            }
            else break;

        }
        ans*=(j+1);
    }
    printf("%I64d\n",ans);
    return 1;
}
int main()
{
    while(init());
   return 0;
}


你可能感兴趣的:(ACM)