• 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 }
  • 相关阅读:
    Python os模块的使用
    数据分析 关于基础组件与介绍
    [SRH.Docker] HBase Java 第一天学习记录
    eclipse创建android项目失败的问题 [ android support library ]
    mysql学习总结
    celery的定时运用
    django认证
    django离线插入测试数据
    关于使用git仓库的操作
    小程序笔记
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2667745.html
Copyright © 2020-2023  润新知