HDUOJ---The number of divisors(约数) about Humble Numbers
生活随笔
收集整理的這篇文章主要介紹了
HDUOJ---The number of divisors(约数) about Humble Numbers
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
The number of divisors(約數(shù)) about Humble Numbers
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2039????Accepted Submission(s): 1002
Problem Description 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. Input 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. Output For each test case, output its divisor number, one line per case. Sample Input 4 12 0 Sample Output 3 6 Author lcy Source http://acm.hdu.edu.cn/showproblem.php?pid=1492? Recommend LL 分解質(zhì)因數(shù) 1 //http://acm.hdu.edu.cn/showproblem.php?pid=1492 2 #include<iostream> 3 #include<cstdio> 4 using namespace std; 5 int main() 6 { 7 _int64 i,n,c1,c2,c3,c4; 8 9 while(scanf("%I64d",&n),n) 10 { 11 for(c1=1,i=n;i%2==0&&i!=0;i/=2) 12 c1++; 13 for(c2=1,i=n;i%3==0&&i!=0;i/=3) 14 c2++; 15 for(c3=1,i=n;i%5==0&&i!=0;i/=5) 16 c3++; 17 for(c4=1,i=n;i%7==0&&i!=0;i/=7) 18 c4++; 19 printf("%I64d\n",c1*c2*c3*c4); 20 } 21 return 0; 22 } View Code
?
總結(jié)
以上是生活随笔為你收集整理的HDUOJ---The number of divisors(约数) about Humble Numbers的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 悉数11种主流NoSQL文档型数据库
- 下一篇: Hadoop依赖包处理方式