http://acm.hdu.edu.cn/showproblem.php?pid=1492
这道题目就是一道数学题,题意大致为问某个数是否为“谦虚数”,就是满足所有的因子都是由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 ;
}