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 ...
随机推荐
- 向txt文件中写入换行
char ret[2];//向记事本中写入这个char数组可以实现换行 ret[0] = 13;// \r ret[1] = 10;// \n fwrite(ret, 2, 1, pFile);
- Windows计划任务执行时不显示窗口的问题
最近开发了工具,带界面的,需要定时执行的,为了方便直接用Windows计划任务做定时了.跑了一段时间发现,进程中也有,就是看不到程序的界面,进程的执行貌似也阻塞了. 从网上查了下,发现时启动方式的问题 ...
- Linux 日常命令
命令 介绍说明 pwd 打印出当前所在目录 mkdir 创建一个目录 rmdir 删除一个目录 rm 删除文件或目录 -r:删除目录时必须加上 cp 复制一个文件或目录 -r:复制 ...
- XAF应用开发教程-内置Attribute功能列表
在 XAF 框架,一些用来生成一个业务应用程序的信息是在Attribute中指定.您可以将属性应用到业务类 (或它的成员) 指定验证规则,指定如何对数据进行显示. 设置关系类等.本主题提供了有关在何处 ...
- D3.js 力导向图
花了大半天看了一个八十几行的代码..心累 力导向图是之前就有画过很多次的东西,但是这次的代码看上去很陌生,然后发现是D3更新了4.0.... 先贴代码 var svg = d3.select(&quo ...
- mac 显示set a breakpoint in malloc_error_break to debug 终端显示进程已完成怎么办?
mac 终端显示 ,0x7fff73dbd300) malloc: *** error for object 0x7fce52d15100: pointer being freed was not a ...
- mac 安装redis
一.下载 官网http://redis.io/ (搞不懂为啥被墙) 二.安装 将下载的tar.gz文件复制到 /usr/local 文件夹下 解压 sudo tar -zxvf redis3.1.6. ...
- 使用java自带线程池管理器demo
1.程序入口:DabianTest package com.lbh.myThreadPool.present; import java.util.concurrent.ExecutorService; ...
- Install PaddlePaddle (Parallel Distributed Deep Learning)
Step 1: Install docker on your linux system (My linux is fedora) https://docs.docker.com/engine/inst ...
- <转>下一代Asp.net开发规范OWIN(1)—— OWIN产生的背景以及简单介绍
2014-09-04 07:22 by JustRun http://www.cnblogs.com/JustRun1983/p/3955238.html 随着VS2013的发布,微软在Asp.Net ...