hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式

Posted 努力努力再努力x

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式相关的知识,希望对你有一定的参考价值。

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1492

题目大意:

给出一个数,因子只有2 3 5 7,求这个数的因子个数

解题思路:

直接求出指数即可

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cmath>
 6 #include<queue>
 7 #include<stack>
 8 #include<map>
 9 #include<sstream>
10 #define Mem(a, b) memset(a, b, sizeof(a))
11 using namespace std;
12 typedef long long ll;
13 const int INF = 1e9 + 7;
14 const int maxn = 1000000+10;
15 int a[] = {2,3,5,7};
16 int b[10];
17 ll n;
18 int main()
19 {
20     while(scanf("%lld", &n) != EOF && n)
21     {
22         Mem(b, 0);
23         for(int i = 0; i < 4; i++)
24         {
25             if(n % a[i] == 0)
26             {
27                 while(n % a[i] == 0)
28                 {
29                     b[i]++;
30                     n /= a[i];
31                 }
32             }
33         }
34         ll ans = 1;
35         for(int i = 0; i < 4; i++)
36         {
37             ans *= (b[i] + 1);
38         }
39         printf("%lld\\n", ans);
40     }
41     return 0;
42 }

 

以上是关于hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式的主要内容,如果未能解决你的问题,请参考以下文章

ValueError: The number of elements in ‘fill‘ does not match the number of bands of the image (3 != 4

*Find the Number Occurring Odd Number of Times

NiFi PutKudu错误:the number of replicas does not equal the number of servers解决方案

算法9:What is the sum of the digits of the number 21000

hdu1492(约数个数定理)

tne number which is made of the number of remaining is smallest