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 }
  • 相关阅读:
    Thinkphp 获取当前url
    Navicat Premium 11 For Mac 注册机
    android 客户端支付宝 php服务器端编写
    tp框架集成支付宝,中转页变成gbk编码
    sql,插入最大值加1
    获取php的配置
    百度授权回调问题
    模拟新浪微博textarea,刷新页面输入信息保留
    同一客户端使用多份SSH Key
    SSH 自动化安装部署遇到的问题
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2667745.html
Copyright © 2011-2022 走看看