#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[]={"st","nd","rd"};
int t=x%;
if(t==&&x%!=)s=ss[];
else if(t==&&x%!=)s=ss[];
else if(t==&&x%!=)s=ss[];
return s;
}
int main()
{
//freopen("acm.acm","r",stdin);
int n,len,i,t,m;
len=;
int a[],x2=,x3=,x5=,x7=;
a[]=;
while(len <= )
{
m=min_4(a[x2]*,a[x3]*,a[x5]*,a[x7]*);
if(m==a[x2]*)x2++;
if(m==a[x3]*)x3++;
if(m==a[x5]*)x5++;
if(m==a[x7]*)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-]);
printf(".\n");
}
return ;
}

POJ 2247的更多相关文章

  1. 递推(三):POJ中的三道递推例题POJ 1664、POJ 2247和POJ 1338

    [例9]放苹果(POJ 1664) Description 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法. In ...

  2. Poj 2247 Humble Numbers(求只能被2,3,5, 7 整除的数)

    一.题目大意 本题要求写出前5482个仅能被2,3,5, 7 整除的数. 二.题解 这道题从本质上和Poj 1338 Ugly Numbers(数学推导)是一样的原理,只需要在原来的基础上加上7的运算 ...

  3. POJ 2247 Humble Numbers

    A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...

  4. POJ 2591 1338 2545 2247(数列递归衍生问题,思路挺妙)

    四道题的难度: 2591<1338<2545<2247 POJ 2591 Set Definition: 这是从discuss里看来的,写的挺好,直接copy,根据我的代码稍有改动( ...

  5. POJ 2545+2591+2247+1338简单水题

    [题意简述]:就是有这种一个序列.就拿当p1 = 2,p2 = 3, p3 = 5,来举例.由这三个数为基准组成的序列是: 2,3,4,5,6,8,9,10,12--如今给你这个序列数组的下标,让你求 ...

  6. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  7. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  8. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

  9. poj 题目分类(1)

    poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...

随机推荐

  1. 2018.09.12 earthquake(最优比率生成树)

    描述 地震已经破坏了农夫约翰所有的农场以及所有连接农场的道路.作为一个意志坚强的人,他决定重建所有的农场.在重建全部N(1 <= N <= 400)个农场之前,首先必须把所有农场用道路连接 ...

  2. hdu-1140(求距离,精度判断)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1140 思路:卫星只能消灭地面上一部分的风暴,即风暴与卫星的距离最大是卫星到地球的切线的距离,大于这个距 ...

  3. Django介绍(2)

    https://www.cnblogs.com/yuanchenqi/articles/5658455.html

  4. python网页爬虫 spiders_97A-04B

    import urllib import urllib.request import bs4 from bs4 import BeautifulSoup as bs import re import ...

  5. JSTL 、 OGNL 与 EL

    JSTL: JSP Standard Tag Library OGNL:Object-Graph Navigation Language EL:Expression Language action 中 ...

  6. PRId64的正确用法

    #include <inttypes.h> #include <stdint.h> #include <stdio.h> // g++ -g -o x x.cpp ...

  7. mac下svn无法上传.a文件的问题

    Xcode自带的svn和Versions以及一些其它工具都默认ignore".a"文件. 解决办法有两个: 方法一:使用命令行添加文件([转]原文在这) 1.打开终端,输入cd,空 ...

  8. struts2 一些注解

    实现的JSP页面位置 web-root/jsp/user/add.jsp /update.jsp // /* @Namespace("/t") @AllowedMethods(va ...

  9. vim 配置半透明

    转载两个博客 链接一 链接二

  10. DagScheduler 和 TaskScheduler

    DagScheduler 和 TaskScheduler 的任务交接 spark 调度器分为两个部分, 一个是 DagScheduler, 一个是 TaskScheduler, DagSchedule ...