标签:targe queue set font strong php fine 约数 lan
题目链接:
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---因子数公式
标签:targe queue set font strong php fine 约数 lan
原文地址:https://www.cnblogs.com/fzl194/p/9017433.html