zoukankan      html  css  js  c++  java
  • HDU 1492

    The number of divisors(约数) about Humble Numbers

    Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 1708 Accepted Submission(s): 833


    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
     1 #include<stdio.h>
     2 int main()
     3 {
     4     long long n;
     5     int p2,p3,p5,p7;
     6     while(scanf("%I64d",&n),n)
     7     {
     8         p2=p3=p5=p7=0;
     9         while(n%2==0)
    10         {
    11             n/=2;
    12             p2++;
    13         }    
    14         while(n%3==0)
    15         {
    16             n/=3;
    17             p3++;
    18         }    
    19         while(n%5==0)
    20         {
    21             n/=5;
    22             p5++;
    23         }    
    24         while(n%7==0)
    25         {
    26             n/=7;
    27             p7++;
    28         }    
    29         printf("%d\n",(p2+1)*(p3+1)*(p5+1)*(p7+1));//乘法原理,2 3 5 7可以一个都不要所以必须加一 
    30     }    
    31     return 0;
    32 }
  • 相关阅读:
    Quartz.Net定时器
    Lucene.Net 实现搜索功能
    哈希表 STL map
    买卖股票的最佳时机I II III IV
    [离散化]人潮最多的時段( Interval Partitioning Problem )
    动态规划[入门]3-更难的矩阵取数问题
    动态规划[入门3]-多重背包问题
    动态规划[入门]2-循环数组最大子段和
    catalan卡塔兰数
    逆波兰表达式
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2667745.html
Copyright © 2011-2022 走看看