A - Humble Numbers
Description
Write a program to find and print the nth element in this sequence
Input
of one integer n with 1 <= n <= 5842. Input is terminated by a
value of zero (0) for n.
Output
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
2
3
4
11
12
13
21
22
23
100
1000
5842
0
Sample Output
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.
The 5842nd humble number is 2000000000.
#include<cstdio>
#include<string.h>
using namespace std;
const int MAXN=;
int num2=,num3=,num5=,num7=;
long long s[MAXN];
void Sort()//sort函数是用来求humble number数组的
{
s[]=;
s[num2]=,s[num3]=,s[num5]=;
long long min=s[num2]*;
int num2=,num3=,num5=,num7=;
for(int i=;i<;i++)
{ min=s[num2]*;
if(min>s[num3]*)
min=s[num3]*;
if(min>s[num5]*)
min=s[num5]*;
if(min>s[num7]*)
min=s[num7]*;
s[i]=min;
// printf("%d ",s[i]);
//printf("%d ",min);
if(min==s[num2]*)
num2++;
if(min==s[num3]*)
num3++;
if(min==s[num5]*)
num5++;
if(min==s[num7]*)
num7++;
}
}
int main()
{
int n;
Sort();
while(scanf("%d",&n)!=EOF&&n)
{
if(n%==&&n%!=&&n!=)//当时卡在n%100!=11和12,13这里了,wa了几次!
printf("The %dst humble number is ",n);
else if(n%==&&n%!=&&n!=)
printf("The %dnd humble number is ",n);
else if(n%==&&n%!=&&n!=)
printf("The %drd humble number is ",n);
else printf("The %dth humble number is ",n);
printf("%lld.\n",s[n-]);
}
return ;
}
A - Humble Numbers的更多相关文章
- [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 ...
- 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 ...
- The number of divisors(约数) about Humble Numbers[HDU1492]
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- Humble Numbers
Humble Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9988 Accepted: 4665 Descri ...
- 洛谷P2723 丑数 Humble Numbers
P2723 丑数 Humble Numbers 52通过 138提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目背景 对于一给定的素数 ...
- HDU 1058 Humble Numbers (DP)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDOJ 1058 Humble Numbers(打表过)
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- The number of divisors(约数) about Humble Numbers
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- HDU1058 Humble Numbers 【数论】
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
随机推荐
- [问题2014A02] 复旦高等代数 I(14级)每周一题(第四教学周)
[问题2014A02] 求下列 \(n\) 阶行列式的值, 其中 \(a_i\neq 0\,(i=1,2,\cdots,n)\): \[ |A|=\begin{vmatrix} 0 & a_ ...
- String和string的区别
(1)从位置讲 1.string是c#中的的 2.String是 .Net Framework的一个函数名(类),基于using.System的引用 (2)从性质讲 1.string是关键字,Stri ...
- centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)
之前都用的lamp,这次配置一个lnmp来看看,试试Nginx是不是好用 关闭SELINUXvi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXT ...
- 配置org.springframework.scheduling.quartz.CronTriggerBean (转载)
在项目中又用到了定时器,对于定时器的应用总是模模糊糊的,今天结合网上找到的资料与自己在项目中写的简单地在此写一下,以备需要时查阅. 一个Quartz的CronTrigger表达式分为七项子表达式,其中 ...
- Android 自定义波浪动画 --"让进度浪起来~"
原文链接:http://www.jianshu.com/p/0e25a10cb9f5 一款效果不错的动画,实现也挺简单的,推荐阅读学习~ -- 由 傻小孩b 分享 waveview <Andro ...
- iOS 启动图那些坑
当我们按照图片尺寸要求将所有的图片添加到工程中后,上传打包的工程时可能会出现一个问题:说工程中不存在启动图.但是我们明明已经导入启动图了,那么问题出在哪呢.我经过多次试验,发现压缩过后的图片作为启动图 ...
- jq知识总结
jQuery jQuery基本选择器: id选择器 $("#div1") class选择器 $(".div1") 元素选择器 $(" ...
- freemarker if elseif
FreeMarker模板 if, else, elseif 指令 : if, else, elseif 语法 <#if condition> ... <#elseif conditi ...
- 修改placeholder提示内容的颜色以及文本框输入文字内容的颜色
一般表单文本框提示信息:placeholder=" ",默认颜色是灰色的,输入文本信息也是默认为黑色的,如图所示: 修改placeholder提示内容的颜色关键代码及实现: 实现输 ...
- 16 款最流行的 JavaScript 框架
本文列举了16个当前最流行的JavaScript框架.在这个列表中,既包括jQuery和Mootools,也有Zepo移动JavaScript框架. 里面一定有你正在用的或想尝试用的JavaScrip ...