The number of divisors(约数) about Humble Numbers
2013-04-21 21:57
344 查看
The number of divisors(约数) about Humble Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1887 Accepted Submission(s): 925
[align=left]Problem Description[/align]
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.
Now given a humble number, please write a program to calculate the number of divisors about this humble number.For examle, 4 is a humble,and it have 3 divisors(1,2,4);12 have 6 divisors.
[align=left]Input[/align]
The input consists of multiple test cases. Each test case consists of one humble number n,and n is in the range of 64-bits signed integer. Input is terminated by a value of zero for n.
[align=left]Output[/align]
For each test case, output its divisor number, one line per case.
[align=left]Sample Input[/align]
4 12 0
[align=left]Sample Output[/align]
3 6
[align=left]Author[/align]
lcy
思路:
如果一个数n有质因子a,b,c...
n=a^a1*b^b1.....
则约数个数有
(a1+1)*(b1+1).....
#include<iostream> #include<cstdio> using namespace std; int main() { __int64 n; while(scanf("%I64d",&n)&&n!=0){ __int64 a[4]; memset(a,0,sizeof(a)); int i=0; while(n%2==0){ n=n/2; a[i]++; } i++; while(n%3==0){ n/=3; a[i]++; } i++; while(n%5==0){ n/=5; a[i]++; } i++; while(n%7==0){ n/=7; a[i]++; } __int64 sum=1; for(i=0;i<4;i++) sum*=(a[i]+1); printf("%I64d\n",sum); } return 0; }
相关文章推荐
- ACM--约数--HDOJ 1492--The number of divisors(约数) about Humble Numbers
- HDU1492-The number of divisors(约数) about Humble Numbers-数论(计数问题)
- The number of divisors(约数) about Humble Numbers
- ACM 数论 hdu 1492 The number of divisors(约数) about Humble Numbers
- 杭电1492 The number of divisors(约数) about Humble Numbers
- The number of divisors(约数) about Humble Numbers--hdu1492
- HDU1492 The number of divisors(约数) about Humble Numbers
- hdoj 1492 The number of divisors(约数) about Humble Numbers 【数论】【质因子分解 求和】
- The number of divisors(约数) about Humble Numbers
- The number of divisors(约数) about Humble Numbers
- hdu1492-The number of divisors(约数) about Humble Numbers
- 杭电 1492 The number of divisors(约数) about Humble Numbers
- hdu1492 The number of divisors(约数) about Humble Numbers(公约数个数问题)
- HDU 1492 The number of divisors(约数) about Humble Numbers
- HDU1492 The number of divisors(约数) about Humble Numbers【约数】
- The number of divisors(约数) about Humble Numbers(有多少因数)
- HDUOJ---The number of divisors(约数) about Humble Numbers
- HDU 1492 The number of divisors(约数) about Humble Numbers(数论题目要知道定理呀....)
- The number of divisors(约数) about Humble Numbers[HDU1492]
- hdu1492 The number of divisors(约数) about Humble Numbers