博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1058 Humble Numbers
阅读量:6271 次
发布时间:2019-06-22

本文共 1715 字,大约阅读时间需要 5 分钟。

Humble Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10972    Accepted Submission(s): 4780

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.
Write a program to find and print the nth element in this sequence
 
Input
The input consists of one or more test cases. Each test case consists of one integer n with 1 <= n <= 5842. Input is terminated by a value of zero (0) for n.
 
Output
For each test case, print one line saying "The nth humble number is number.". Depending on the value of n, the correct suffix "st", "nd", "rd", or "th" for the ordinal number nth has to be used like it is shown in the sample output.
 
Sample Input
 
1
2
3
4
11
12
13
21
22
23
100
1000
5842
0
 
Sample Output
 
The 1st humble number is 1.
The 2nd humble number is 2.
The 3rd humble number is 3.
The 4th humble number is 4.
The 11th humble number is 12.
The 12th humble number is 14.
The 13th humble number is 15.
The 21st humble number is 28.
The 22nd humble number is 30.
The 23rd humble number is 32.
The 100th humble number is 450.
The 1000th humble number is 385875. T
he 5842nd humble number is 2000000000.
 
Source
 
Recommend
JGShining
 
 
 
题意大体是:humble number由2,3,5,7因数组成,,,然后解题即可,,,注意1的时候是1
 
 
 
#include
long long num[5843];int main(){ num[1]=1; int i,j,k; int prime[4]={
2,3,5,7}; for(i=2;i<=5842;i++){ num[i]=2000000001; for(j=0;j<4;j++) for(k=i-1;k>=1;k--){ if(num[k]*prime[j]<=num[i-1]) break; if(num[k]*prime[j]

 

转载地址:http://hblpa.baihongyu.com/

你可能感兴趣的文章
搭建Hexo博客进阶篇---主题自定义(三)
查看>>
【Mysql中间件】Mycat安装部署+读写分离
查看>>
这3家在线旅行公司是如何通过转化优化提高订单量的
查看>>
RocketMq使用过程的那些小事
查看>>
Autodesk Forge 学习简谈 - 4
查看>>
OWNER支持配置文件目录的继承
查看>>
Walls and Gates
查看>>
JavaScript 继承的那些事
查看>>
Scala中的函数式特性
查看>>
脱离“体验”和“安全”谈盈利的游戏运营 都是耍流氓
查看>>
试水区块链出版?纽约时报在招人了
查看>>
拥抱PostgreSQL,红帽再表态:SSPL的MongoDB坚决不用
查看>>
让架构更简单,QCon上海2016热点前瞻
查看>>
如何测试ASP.NET Core Web API
查看>>
SQL Server新一轮更新
查看>>
想像亚马逊或 Netflix 一样酷?抱走敏捷转型五大秘籍
查看>>
《Git in Practice》作者访谈:关于Git的八个问题
查看>>
Visual Studio 2019正式版发布,专注于人工智能和生产力
查看>>
写给Java程序员的Java虚拟机学习指南
查看>>
苏宁11.11:如何基于异步化打造会员任务平台?
查看>>