#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define inf 1<<31
int f[6000];
int n;
int minn(int a, int b, int c, int d)
{
int Min1 = a < b ? a : b;
int Min2 = c < d ? c : d;
return Min1 < Min2 ? Min1 : Min2;
}
int main()
{
int x2,x3,x5,x7;
int a,b,c,d;
x2=1;
x3=1;
x5=1;
x7=1;
f[1]=1;
for(int i=2;i<=5999;i++)
{
a=f[x2]*2;
b=f[x3]*3;
c=f[x5]*5;
d=f[x7]*7;
f[i]=minn(a,b,c,d);
if(f[i]==a)
{
x2++;
}
if(f[i]==b)
{
x3++;
}
if(f[i]==c)
{
x5++;
}
if(f[i]==d)
{
x7++;
}
}
while(~scanf("%d",&n) && n)
{
printf("The %d",n);
if(n % 10 == 1 && n % 100 != 11)
printf("st");
else if(n % 10 == 2 && n % 100 != 12)
printf("nd");
else if(n % 10 == 3 && n % 100 != 13)
printf("rd");
else
printf("th");
printf(" humble number is %d.\n",f[n]);
}
return 0;
}
hdu1058
最新推荐文章于 2020-12-23 13:39:08 发布