這道題目就是一道數學題,題意大致為問某個數是否為“謙虛數”,就是滿足所有的因子都是由2 , 3 , 5 , 7 這四個質因子所組成的數據,然後問這個數有多少個因子;
解法:就是將數據拆分,統計每個素因子的個數,然後直接相乘即可,至於為什麼,自己看數論有關書籍。需要注意的就是最後直接取余統計的話,最終剩下的結果為1,所以使用循環判斷n是否為1, 判斷語句 if 也可以
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define LL long long
int main()
{
LL n ;
int a , b , c , d ;
while( cin >> n , n )
{
a = b = c = d = 1 ;
while( n != 1 )
{
while( n % 2 == 0 )
{
n /= 2 ;
a++ ;
}
while( n % 3 == 0 )
{
n /= 3 ;
b++ ;
}
while(n % 5 == 0 )
{
n /= 5 ;
c++ ;
}
while( n % 7 == 0 )
{
n /= 7 ;
d++ ;
}
}
cout << ( a * b * c * d ) << endl ;
}
return 0 ;
}