hdoj 1058 Humble Numbers(dp)
2012-10-25 17:43
519 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1058
st[i]=min{st[a]*2,st[b]*3,st[c]*5,st[d]*7}
View Code
st[i]=min{st[a]*2,st[b]*3,st[c]*5,st[d]*7}
View Code
#include <iostream> #include<cstdio> #include<cstring> using namespace std; int main() { long int n; long int st[5850]; long int a=1,b=1,c=1,d=1,small,i; st[1]=1; for(i=2;i<5850;i++) { small=st[a]*2; if(small>st[b]*3) small=st[b]*3; if(small>st[c]*5) small=st[c]*5; if(small>st[d]*7) small=st[d]*7; if(small==st[a]*2) a++; if(small==st[b]*3) b++; if(small==st[c]*5) c++; if(small==st[d]*7) d++; st[i]=small; } while(scanf("%ld",&n)) { if(n==0) break; if(n%10==1&&n%100!=11) printf("The %ldst humble number is %ld.\n",n,st ); else if(n%10==2&&n%100!=12) printf("The %ldnd humble number is %ld.\n",n,st ); else if(n%10==3&&n%100!=13) printf("The %ldrd humble number is %ld.\n",n,st ); else printf("The %ldth humble number is %ld.\n",n,st ); } return 0; }
相关文章推荐
- HDOJ---1058 Humble Numbers[DP]
- hdoj1058_Humble Numbers(dp)
- HDOJ 1058 Humble Numbers解题报告【DP】
- hdoj-1058-Humble Numbers【DP&】
- hdoj 1058 Humble Numbers【dp】
- HDOJ(HDU).1058 Humble Numbers (DP)
- HDOJ-----1058---Humble Numbers(DP)
- HDOJ1058(Humble Numbers)dp
- HDOJ1058 Humble Numbers DP简单题
- hdu 1058:Humble Numbers(动态规划 DP)
- HDU 1058 Humble Numbers(dp)
- hdu1058 Humble Numbers(丑数) —— dp
- HDU 1058 Humble Numbers【DP】
- hdu 1058 Humble Numbers【dp】
- HDOJ 1058:Humble Numbers 寻找丑数问题 解题报告
- hdu 1058 Humble Numbers (DP初步)
- HDOJ 1058 Humble Numbers
- HDU 1058 Humble Numbers && NOJ 1420 丑数 (数位dp)
- hdu 1058 Humble Numbers(dp)
- HDU-1058 Humble Numbers(线性dp 枚举因子个数)