hdu 1058
这道题有很多种做法,但是思路大都是一样的,代码有点类似于poj2591这道题。
题意:问因子只含有2,3,5,7的第k个数是什么?
#include<stdio.h>
int f[5843],n;
int i,j,k,l;
int Min(int a,int b,int c,int d)
{
int _min = a;
if(b<_min) _min = b;
if(c<_min) _min = c;
if(d<_min) _min = d;
if(a==_min) i++;
if(b==_min) j++;
if(c==_min) k++;
if(d==_min) l++;
return _min;
}
int main()
{
i=j=k=l=1;
f[1] = 1;
for(int t=2;t<=5842;t++)
f[t] = Min(2*f[i],3*f[j],5*f[k],7*f[l]);
while(scanf("%d",&n),n)
{
if(n%100==11||n%100==12||n%100==13)
printf("The %dth humble number is %d.\n",n,f[n]);
else if(n%10==1)
printf("The %dst humble number is %d.\n",n,f[n]);
else if(n%10==2)
printf("The %dnd humble number is %d.\n",n,f[n]);
else if(n%10==3)
printf("The %drd humble number is %d.\n",n,f[n]);
else
printf("The %dth humble number is %d.\n",n,f[n]);
}
return 0;
}
hdu 1058的更多相关文章
- hdu 1058 dp.Humble Numbers
Humble Numbers Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Subm ...
- HDOJ(HDU).1058 Humble Numbers (DP)
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...
- HDU 1058 Humble Numbers(离线打表)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1058 解题报告:输入一个n,输出第n个质因子只有2,3,5,7的数. 用了离线打表,因为n最大只有58 ...
- HDU 1058(打表)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1058 Humble Numbers Time Limit: 2000/1000 MS (Java/O ...
- HDU 1058 优先队列or堆
本来应当是一道优先队列或者堆的题 因为每个数都应该是已经得到的数*2 *3 *5 *7而得到的 但是 2*7 大于 3*2 这就必须保证每次取得都是没有拿过的最小的数 但是它主动降低难度在样例里卖了个 ...
- hdu 1058 Humble Numbers
这题应该是用dp来做的吧,但一时不想思考了,写了个很暴力的,类似模拟打表,然后排序即可,要注意的是输出的格式,在这里wa了一发,看了别人的代码才知道哪些情况没考虑到. #include<cstd ...
- HDU 1058 Humble Numbers【DP】
题意:给出丑数的定义,只含有2,3,5,7这四个素数因子的数称为素数.求第n个丑数. 可以先观察几个丑数得出规律 1:dp[1] 2:min(1*2,1*3,1*5,1*7) 3:min(2*2,1* ...
- HDU 1058 Humble Numbers (DP)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- HDU 1058 Humble Number
Humble Number Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humbl ...
- Humble Numbers HDU - 1058
A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...
随机推荐
- MySql重复查询
MYSQL查询重复记录的方法很多,下面就为您介绍几种最常用的MYSQL查询重复记录的方法,希望对您学习MYSQL查询重复记录方面能有所帮助. 1.查找表中多余的重复记录,重复记录是根据单个字段(peo ...
- ora-01652无法通过128(在temp表空间中)扩展temp段
有两种错误:1.数据表空间不足 2.临时表空间不足 有两种原因:一是临时表空间空间太小,二是不能自动扩展. 分析过程: 既然是temp表空间有问题,那当然就要从temp表空间说起啦.首先要说明的 ...
- ORACLE用户永不被锁
alter profile default limit FAILED_LOGIN_ATTEMPTS UNLIMITED;
- SharePoint 2010 外部数据类型
需求描述: 在sharepoint 2010有时需要访问外部的数据(如sql数据库). 参考文章: 外部内容类型 Business Connectivity Services ECT外部内容类型 Se ...
- httpclient4例子
参考:http://hc.apache.org/httpclient-3.x/tutorial.html import org.apache.http.HttpEntity; import org.a ...
- Required String parameter ' ' is not present
Required String parameter ' ' is not present 报错原因: url中的参数错误. 解决方法: 1.修正url中的参数的值. 2.在Controller层中的@ ...
- queue,stack的相互实现
Implement Queue using Stacks [抄题]: [思维问题]: [一句话思路]: 取头部.取出来的时候,用一个output来倒序 [输入量]:空: 正常情况:特大:特小:程序里处 ...
- 旋转链表(所有元素往右移) rotate list
[抄题]: 给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数 样例 给出链表1->2->3->4->5->null和k=2 返回4->5-& ...
- Centos7下安装apache2.4 php5.6 pdo_oci oci8
一.下载必须的安装源码包 http://httpd.apache.org/download.cgi#apache24 httpd-2.4.23.tar.gz http://apr.apache.org ...
- Asia Stock Exchanges[z]
Asia Stock Exchanges July 7, 2009 This article is to summarise the trading rules of some Asia stocke ...