HDU 1058 DP
来源:互联网 发布:好看的鲨鱼电影知乎 编辑:程序博客网 时间:2024/05/19 09:14
自己做的时候没想法。。。。好渣啊好渣怎么办!。。。。
觉得这样的题不算DP吧。。。感觉不大。就是轮流找素数因子,每次把找到最小的那个值更新,觉得方法挺巧的。说是很卡输出格式,估计还顺便考英语。。。不过有前辈助力,所以没有纠结太久 。
#include <stdio.h>#define maxn 60000int ar[maxn];int min(int a,int b,int c,int d){ int t1=a>b?b:a; int t2=c>d?d:c; return t1>t2?t2:t1;}void find(){ int i,a,b,c,d; int n1,n2,n3,n4; ar[1]=1; n1=n2=n3=n4=1; for(i=2;i<maxn;i++) { a=ar[n1]*2; b=ar[n2]*3; c=ar[n3]*5; d=ar[n4]*7; ar[i]=min(a,b,c,d); if(ar[i]==a) n1++; if(ar[i]==b) n2++; if(ar[i]==c) n3++; if(ar[i]==d) n4++; }}int main(){ int n; find(); while(scanf("%d",&n),n!=0) { int i,j; i=n/10; j=i%10; //if(n%10==1&&j==1) printf("The %dth humble number is %d.\n",n,ar[n]); if(n%10==1&&j!=1) printf("The %dst humble number is %d.\n",n,ar[n]); else if(n%10==2&&j!=1) printf("The %dnd humble number is %d.\n",n,ar[n]); else if(n%10==3&&j!=1) printf("The %drd humble number is %d.\n",n,ar[n]); else printf("The %dth humble number is %d.\n",n,ar[n]); } return 0;}
0 0
- hdu 1058 DP
- hdu 1058 (DP)
- hdu 1058 dp
- HDU 1058(DP)
- HDU 1058 DP
- hdu 1058(dp)
- hdu 1058 dp解法
- HDU 1058 DP
- HDU 1058 DP
- hdu 1058 Humble Numbers (DP)
- HDU 1058 Humble Number DP
- hdu 1058 Humble Numbers (dp)
- hdu 1058 Humble Numbers(dp)
- hdu 1058 Humble Numbers(DP)
- 【DP】HDU-1058 Humble Numbers
- hdu 1058 Humble Numbers【dp】
- hdu 1058 Humble Numbers(dp)
- HDU 1058 Humble Numbers dp
- Java学习笔记(十)String类和StringBuffer类
- 新手学习C++笔记3:调试错误之C与C++的区别
- Python模块学习 ---- random 随机数生成
- HDU1398-Square Coins
- [水]ZOJ1405
- HDU 1058 DP
- Apache设置多网站
- Delphi各版本号,条件编译有用
- wordpress 判断浏览终端是 pc 还是 mobile 模式 使用插件 Any Mobile Theme Switcher
- 上色后图片
- Mini播放器_设计二
- ORACLE 常用函数——聚合函数
- Codeforces Round #260 (Div. 2)-A,B,C
- POJ 3087 Shuffle'm Up (模拟)