HDU1492/The number of divisors(约数) about Humble Numbers
The number of divisors(约数) about Humble Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3416 Accepted Submission(s): 1676
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
“2006校园文化活动月”之“校庆杯”大学生程序设计竞赛暨杭州电子科技大学第四届大学生程序设计竞赛
/*
求一个数的约数:x=p1^x1 * p2^x2 * p3^x3.....
p1\p2\p3分别为素数,那么x的约数的个数就是ans=(x1+1)*(x2+1)*(x2+1)....
*/
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long LL;
using namespace std;
int a[6]={2,3,5,7};
int main ()
{
LL n;
while(scanf("%lld",&n),n)
{
LL ans=1;
int i=0;
int t=0;
while(n)
{
if(n%a[i]==0)
{
t++;
n/=a[i];
}
else
{
ans*=(t+1);
t=0;
i++;
if(n==1)
break;
}
}
printf("%lld\n",ans);
}
return 0;
}
HDU1492/The number of divisors(约数) about Humble Numbers的更多相关文章
- The number of divisors(约数) about Humble Numbers[HDU1492]
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- The number of divisors(约数) about Humble Numbers
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- HDUOJ---The number of divisors(约数) about Humble Numbers
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- HDU - The number of divisors(约数) about Humble Numbers
Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence ...
- 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, ...
- hdu-1492 The number of divisors(约数) about Humble Numbers---因子数公式
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1492 题目大意: 给出一个数,因子只有2 3 5 7,求这个数的因子个数 解题思路: 直接求出指数即 ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- A - Humble Numbers
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Pract ...
- Humble Numbers
Humble Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9988 Accepted: 4665 Descri ...
随机推荐
- 5.Hibernate实现全套增删改查和ajax异步分页
1.1 创建如下oracle数据库脚本 drop sequence seq_stu; create sequence SEQ_STU minvalue maxvalue start increment ...
- 一、ASP.NET Routing路由(深入解析路由系统架构原理)
阅读目录: 1.开篇介绍 2.ASP.NET Routing 路由对象模型的位置 3.ASP.NET Routing 路由对象模型的入口 4.ASP.NET Routing 路由对象模型的内部结构 4 ...
- CDOJ 1270 Playfair(模拟)
题目链接 Playfair is a kind of substitution cipher.And the encryption role is simple.In general,there ar ...
- MVC3+EF4.1学习系列(二)-------基础的增删改查和持久对象的生命周期变化
上篇文章中 我们已经创建了EF4.1基于code first的例子 有了数据库 并初始化了一些数据 今天这里写基础的增删改查和持久对象的生命周期变化 学习下原文先把运行好的原图贴来上~~ 一.创建 ...
- Excel教程(11) - 查找和引用函数
ADDRESS 用途:以文字形式返回对工作簿中某一单元格的引用. 语法: sheADDRESS(row_num,column_num,abs_num,a1,et_text) 参数:Row_num ...
- java 内部类(摘抄自网络)
Java内部类 1.内部类分为成员内部类.静态嵌套类.方法内部类.匿名内部类. 几种内部类的共性: A.内部类仍然是一个独立的类,在编译之后会内部类会被编译成独立的.class文件,但是前面冠以外部类 ...
- 大数据加减(Big data addition and subtraction)
题目描述 Description 加减法是计算中的基础运算,虽然规则简单,但是位数太多了,也难免会出错.现在的问题是:给定任意位数(不超过1000位)的加减法算式,请给出正确结果.为提高速度,保证给定 ...
- Openjudge-计算概论(A)-鸡尾酒疗法
描述: 鸡尾酒疗法,原指“高效抗逆转录病毒治疗”(HAART),由美籍华裔科学家何大一于1996年提出,是通过三种或三种以上的抗病毒药物联合使用来治疗艾 滋病.该疗法的应用可以减少单一用药产生的抗药性 ...
- 写一个CGI程序并运行
准备Linux和Apache我在/var/www/cgi-bin/下建一个文件get.c #include <stdio.h> #include <stdlib.h> int ...
- linux之ls -l|grep "^-"|wc -l命令
查看某文件夹下文件的个数 ls -l |grep "^-"|wc -l 或 find ./company -type f | wc -l 查看某文件夹下文件的个数,包括子文件夹里的 ...