POJ 2247 Humble Numbers
2015-08-05 14:42
459 查看
#include<iostream> #include<algorithm> #define maxnum 2000000000 using namespace std; int a[5850]={0}; int main(){ long long n2=1,n3=1,n5=1,n7=1; int n,count=0; while(n2<=maxnum){ n3=1; while(n2*n3<=maxnum){ n5=1; while(n2*n3*n5<=maxnum){ n7=1; while(n2*n3*n5*n7<=maxnum){ a[++count]=n2*n3*n5*n7; n7*=7; } n5*=5; } n3*=3; } n2*=2; } sort(&a[1], &a[count+1] ); while(cin>>n,n){ if(n%10==1 && n%100!=11) cout<<"The "<<n<<"st humble number is "<<a <<"."<<endl; else if(n%10==2 && n%100!=12) cout<<"The "<<n<<"nd humble number is "<<a <<"."<<endl; else if(n%10==3 && n%100!=13) cout<<"The "<<n<<"rd humble number is "<<a <<"."<<endl; else cout<<"The "<<n<<"th humble number is "<<a <<"."<<endl; } return 0; }
相关文章推荐
- 南邮 OJ 1342 皇后控制问题
- hdu1018 Big Number stirling公式
- powerDesigner自制的最简单的数据库表结构报告文档&表字段布局说明
- HDU 4497 GCD and LCM
- Intel Threading BuildingBlocks(Intel TBB)介绍
- iSight集成Adams/View:Adams组件
- VIM 操作快捷键
- 解决jquery操作checkbox全选全不选无法勾选问题
- 前端各种技术简介
- JS使用parseInt解析数字实现求和的方法
- io.js v3.0.0发布
- java中的StringBuffer类
- 小心别让圆角成了你列表的帧数杀手
- 大讲台谈hive(初篇)
- Android 谷歌 开源 通信框架 VOLLEY(五)——源码架构设计
- 如何通过ildasm/ilasm修改assembly的IL代码
- eclipse 下找不到或无法加载主类的解决办法[转]
- POJ 1163 The Triangle
- java打印的说明文档
- C语言-不同类型数据间的混合运算