POJ 2247
2015-06-10 17:12
267 查看
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<map> using namespace std; int min_4(int a,int b,int c,int d) { a=a<b?a:b; a=a<c?a:c; a=a<d?a:d; return a; } string work(int x) { string s="th"; const string ss[3]={"st","nd","rd"}; int t=x%10; if(t==1&&x%100!=11)s=ss[0]; else if(t==2&&x%100!=12)s=ss[1]; else if(t==3&&x%100!=13)s=ss[2]; return s; } int main() { //freopen("acm.acm","r",stdin); int n,len,i,t,m; len=1; int a[6000],x2=0,x3=0,x5=0,x7=0; a[0]=1; while(len <= 5846) { m=min_4(a[x2]*2,a[x3]*3,a[x5]*5,a[x7]*7); if(m==a[x2]*2)x2++; if(m==a[x3]*3)x3++; if(m==a[x5]*5)x5++; if(m==a[x7]*7)x7++; a[len++]=m; } while(scanf("%d",&n)) { if(!n) break; string s=work(n); printf("The "); printf("%d",n); printf("%s",s.c_str()); printf(" humble number is "); printf("%d",a[n-1]); printf(".\n"); } return 0; }
相关文章推荐
- shell脚本积累
- freetype日记1
- web开发----jsp中通用模版的动态引用其它页面
- PHP中的一些常用函数
- Core Data的基本知识(增删查改) --以及实际项目中学习
- Android缓存Cache学习
- web开发----jsp中通用模版的动态引用其它页面
- 并行计算复习————第四篇 并行计算软件支撑:并行编程
- android模拟器滑动界面时,自动输出'C'的问题
- HTML5漂亮实用的电子书
- POJ 2239
- POJ 2240
- POJ 2242
- SQLServer学习笔记系列7
- 扫描二维码自动识别手机系统(Android/IOS)
- KMP算法
- ubuntu14.04下安装hbse1.0.1.1
- iptables 端口转发功能简单例子
- Win8.1不借助第三方软件怎么给文件夹加密并隐藏
- Kettle-3-使用