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 ---------------------------------------------------------------我是分割线^_^----------------------------------------------------------------- 以后遇到英文题还是多解释一下吧,也是为了自己以后看的时候能更有效率,不然真的题目要看老半天= =。 题目的意思是寻找丑数的约数的个数一共有多少个,不包括自己,所谓丑数,就是约数只包含2,3,5,7(当然
默认的1已经包含进来了,因为除了0之外任何数都有一个约数为1嘛!)
这几个数的数,大概懂了题意之后,应该要想到丑数就是依靠着四个数建立起来的,就是这样:设2,3,5,7的
指数分别为a, b, c, d,则题目给定一个数n,就会有2^a * 3^b * 5^c * 7^d = n, 然后就可以知道了,这个n是由a个2,
b个3,c个5以及d个7乘出来的,接下来就可以组合出n的所有因数了,2最少有0个,最多有a个,同理,3,5,7也
一样,这样a个2,b个3,c个5以及d个7共有a*b*c*d种组合方式,这也就是n的所有因数的个数啦!
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std; #define Int __int64 int main()
{
//freopen("input.txt", "r", stdin);
Int n;
while (scanf("%I64d", &n), n)
{
Int num[4] = {2, 3, 5, 7};
int ans[4] = {1, 1, 1, 1};//由在算的时候没有把0个2,0个3,0个5或者0个7的情况计算进去,所以一开始就加上
for (int i = 0; i < n; i++)
{
while (n != 1 && n % num[i] == 0)//算出2,3,5,7的个数
{
ans[i]++;
n /= num[i];
}
}
printf("%d\n", ans[0] * ans[1] * ans[2] * ans[3]);
}
return 0;
}
 


HDU - The number of divisors(约数) about Humble Numbers的更多相关文章

  1. HDUOJ---The number of divisors(约数) about Humble Numbers

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  2. The number of divisors(约数) about Humble Numbers[HDU1492]

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  3. The number of divisors(约数) about Humble Numbers

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  4. HDU1492/The number of divisors(约数) about Humble Numbers

    题目连接 The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory L ...

  5. HDU-1492-The number of divisors(约数) about Humble Numbers -求因子总数+唯一分解定理的变形

    A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...

  6. hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1492 题目大意: 给出一个数,因子只有2 3 5 7,求这个数的因子个数 解题思路: 直接求出指数即 ...

  7. hdu 1058 dp.Humble Numbers

    Humble Numbers Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Subm ...

  8. HDOJ(HDU).1058 Humble Numbers (DP)

    HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...

  9. HDU 1711 Number Sequence(数列)

    HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

随机推荐

  1. iis 7.5应用程序池自动停止

    今天在我的windows7旗舰版上配置iis7 (Internet Information Server)失败,一直未能启动服务,访问本地网络提示"Service Unavailable H ...

  2. 设计模式学习之外观模式(Facade,结构型模式)(8)

    1.什么是外观模式为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用 2.为什么要使用外观模式在软件开发系统中,客户程序经常会与复杂系统的内 ...

  3. Delphi多线程开发注意事项

    Q1: 多线程中需避免多个线程同时向全局变量进行写入操作,导致访问冲突问题. A1:  可以通过使用加锁机制(比如:临界区.互斥.信号量)解决此问题. Q2:多线程中对于结构体和CLASS类型的全局变 ...

  4. .Learning.Python.Design.Patterns.2nd.Edition之单实例模式

    可以慢慢理解.. 对照JAVA class Singleton(object): def __new__(cls): if not hasattr(cls, 'instance'): cls.inst ...

  5. Python无类再理解--metaclass,type

    上次理解过一次,时间久了,就忘了.. 再学习一次.. http://blog.jobbole.com/21351/ ======================= 但是,Python中的类还远不止如此 ...

  6. Win10 UAP 标题栏

    //自定义标题栏 var view = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView(); ApplicationViewTi ...

  7. PHP二维数组去除重复,重复值相加

    $arr = array( array('id' => 122, 'name' => '张三', 'amount' => '1'), array('id' => 123, 'n ...

  8. 静态/动态函数库设计,王明学learn

    静态/动态函数库设计 Linux应用程序设计中需要的外部函数主要由函数库和系统调用来提供. 两者区别: 一.函数库分类 函数库按照链接方式可分为: 1.静态链接库 对函数库的链接是放在编译时期(com ...

  9. PHP isset()与empty()的使用区别详解(转)

    通过对PHP语言的学习,应该知道它是基于函数的一款HTML脚本语言.庞大的函数库支持着PHP语言功能的实现.下面我们为大家介绍有关PHP函数isset()与empty()的相关用法.     PHP的 ...

  10. codeforce ABBYY Cup 3.0 - Finals (online version) B2. Shave Beaver! 线段树

    B2. Shave Beaver!   The Smart Beaver has recently designed and built an innovative nanotechnologic a ...