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 ...
随机推荐
- 使用dict和set
Python内置了字典:dict的支持,dict全称dictionary,在其他语言中也称为map,使用键-值(key-value)存储,具有极快的查找速度. d = {'Michael': 95, ...
- abiword Related Pages
Application Framework The 'af' directory contains all source code for the cross-platform application ...
- linux mysql 优化
第一 在 /etc/my.cnf 中加入 skip-name-resolve ,重启mysql,这样就能禁用DNS解析,连接速度会快很多.不过,这样的话就不能在MySQL的授权表中使用主机名了而只能用 ...
- centos 6.5 安装 nginx+php+mysql
一.准备工作 (1)配置防火墙 1.首先检查iptables服务的状态 [root@woxplife ~]# service iptables status iptables: Firewall is ...
- Weblogic缓存
缓存:如果脱离IDE工具的话,weblogic的文件会在\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_user文件夹中 ...
- jQuery 序列化表单数据 serialize() serializeArray()
1.serialize()方法 格式:var data = $("form").serialize(); 功能:将表单内容序列化成一个字符串. 这样在ajax提交表单数据时,就不用 ...
- 【Xamarin挖墙脚系列:Xamarin的终极破解步骤(更新)】
前面文章中,我们可以找到对应版本的补丁. Xamarin的 4.0.1717 版本,在补丁的地址中,有作者整理的全部的安装包.迅雷磁力贴: magnet:?xt=urn:btih:9FD298AA61 ...
- 2015第10周四-CSS小结
这两天做前台页面发现个人在CSS前端方法很多基础知识都忘了,晚上又搜索学习了下,把相关内容摘录总结. CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明. selector {declara ...
- CXF之webservice
使用 CXF 做 webservice 简单例子 Apache CXF 是一个开放源代码框架,提供了用于方便地构建和开发 Web 服务的可靠基础架构.它允许创建高性能和可扩展的服务,您可以将这 ...
- poj 1020 Anniversary Cake(切正方形蛋糕+搜索)
...