humble number(hd1058)
Write
a program to find and print the nth element in this sequence
case consists of one integer n with 1 <= n <= 5842. Input is terminated by
a value of zero (0) for n.
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.
/*看题解AC的,结果开始开编译错误了几次,oj说是min()没定义,那为什么自己编译会通过,然后自己写了min(),dp方程 dp[i]=f[i]=min(f[a]*2,min(f[b]*3,min(f[c]*5,f[d]*7)))*/
#include<stdio.h>/*dev编译后运行程序中途闪退,提交后却对的*/
using namespace std;
int min(int a,int b)
{
return a>b?b:a;
}
int humble[];
void factor()/*马丹看了半天也是似懂非懂,比赛时完全想不出来这么求*/
{
int post1=,post2=,post3=,post4=,na,nb,nc,nd,i;
humble[]=;
for(i=;i<=;i++)
{
humble[i]=min(na=humble[post1]*,min(nb=humble[post2]*,min(nc=humble[post3]*,nd=humble[post4]*)));
if(humble[i]==na) post1++;
if(humble[i]==nb) post2++;
if(humble[i]==nc) post3++;
if(humble[i]==nd) post4++;
}
}
int main()
{
int n;
factor();
while(~scanf("%d",&n))
{
if(n==)
break;
printf("The %d",n);
if(n%!=&&n%==)
printf("st");
else if(n%!=&&n%==)
printf("nd");
else if(n%!=&&n%==)
printf("rd");
else
printf("th");
printf(" humble number is %d.\n",humble[n]);
}
}
humble number(hd1058)的更多相关文章
- HDU 1058 Humble Number
Humble Number Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humbl ...
- HDU Problem D [ Humble number ]——基础DP丑数序列
Problem D Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submi ...
- 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 ...
- The number of divisors(约数) about Humble Numbers
The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- HDU1492/The number of divisors(约数) about Humble Numbers
题目连接 The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory L ...
- 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-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, ...
- [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 ...
随机推荐
- bootstrap的datetimepicker控件只选择年月的配置
<script src="{% static "jquery/jquery-1.11.3.min.js" %}"></script> & ...
- Java注释模板设置详解
设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元 ...
- python手记(45)
python 声音编辑,减少音量 #!/usr/bin/env python # -*- coding: utf-8 -*- #http://blog.csdn.net/myhaspl #code:m ...
- java_IO流之 NIO
NIO 定义 即新IO,在JDK1.4的java.nio.*包中引入,其目的在于提高速度. 在Java1.4之前的I/O系统中,提供的都是面向流的I/O系统,系统一次一个字节地处理数据,一个输入流产生 ...
- 【转】100行代码实现最简单的基于FFMPEG+SDL的视频播放器
FFMPEG工程浩大,可以参考的书籍又不是很多,因此很多刚学习FFMPEG的人常常感觉到无从下手.我刚接触FFMPEG的时候也感觉不知从何学起. 因此我把自己做项目过程中实现的一个非常简单的视频播放器 ...
- gdb 调试coredump文件过程
gdb 调试coredump文件过程: 第一步:首先需要一个进程的coredump文件,怎么搞出coredump文件呢? 1. ps -fax|grep 进程名称 找到 ...
- ubuntu下安装xlrd模块,Mysqldb模块
Python中安装xlrd模块 1.从 https://pypi.python.org/pypi/xlrd 下载压缩包 2.解压所下载的压缩包 3.CD到解压文件夹,运行 sudo python s ...
- [英国][记录][战争中的世界:二战全史(26集)][BD-MKV/58G][中英双字][经典收藏]
[英国][记录][战争中的世界:二战全史(26集)][BD-MKV/58G][中英双字][经典收藏] 原片名:The World at War 中文名:战争中的世界 导 演:Ted Childs, ...
- DropDownList 绑定数据后 插入一条不属于表中的数据
ddlFGiftId.DataSource = dtGift; ddlFGiftId.DataTextField = "FGiftName"; ddlFGiftId.DataVal ...
- 为net-snmp添加读readTimeTicks
function readTimeTicks(time){ if(time === 0) return ''; var d = 0, h = 0, m = 0, s = 0; d = parseInt ...