#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
const int inf = 0x3f3f3f;
using namespace std;
__int64 a[6000];
int mutiply(__int64 a[],int p,int r)//排序算法.
{
int i = p - 1;
int j = r + 1;
__int64 x = a[p];
while(1)
{
i++;
while(a[i] < x)
i++;
j--;
while(a[j] > x)
j--;
if(i < j)
{
__int64 ex;
ex = a[i];
a[i] = a[j];
a[j] = ex;
}
else return j;
}
}
void quicksort(__int64 a[],int p,int r)
{
if(p < r)
{
int q = mutiply(a,p,r);
quicksort(a,p,q);
quicksort(a,q+1,r);
}
}
int main()
{
__int64 ans,maxx = 0;int t = 1;
for(int i = 0 ; i<= 31 ;i++)//计算ans = 2^i*3^j*5^k*7^l的每一个数.即为满足条件的数.最后再2排序就OK了.
{
for(int j = 0 ; j <= 31 ; j++)
{
for(int k = 0 ; k <= 31 ; k++)
{
for(int l = 0 ; l <= 31 ; l++)
{
bool vis = 0;
ans = 1;
for(int ss = 0 ; ss < i ; ss++)
{
ans *= 2;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < j ; ss++)
{
ans *= 3;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < k ; ss++)
{
ans *= 5;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < l ; ss++)
{
ans *= 7;
if(ans > 2000000000)
vis = 1;
}
if(!vis)
{
a[t++] = ans;
}
else break;
}
}
}
}
quicksort(a,1,t-1);
int n;
while(scanf("%d",&n) && n!= 0)
{
if((n % 10 == 1 || n % 10 == 2 || n % 10 == 3 ) && n/10%10 == 1)
printf("The %dth humble number is %I64d.\n",n,a[n]);
else
{
if(n % 10 == 3)
printf("The %drd humble number is %I64d.\n",n,a[n]);
if(n % 10 == 2)
printf("The %dnd humble number is %I64d.\n",n,a[n]);
if(n % 10 == 1)
printf("The %dst humble number is %I64d.\n",n,a[n]);
if(n % 10 != 3 && n % 10 != 2 && n % 10 != 1)
printf("The %dth humble number is %I64d.\n",n,a[n]);
}
}
}
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
const int inf = 0x3f3f3f;
using namespace std;
__int64 a[6000];
int mutiply(__int64 a[],int p,int r)//排序算法.
{
int i = p - 1;
int j = r + 1;
__int64 x = a[p];
while(1)
{
i++;
while(a[i] < x)
i++;
j--;
while(a[j] > x)
j--;
if(i < j)
{
__int64 ex;
ex = a[i];
a[i] = a[j];
a[j] = ex;
}
else return j;
}
}
void quicksort(__int64 a[],int p,int r)
{
if(p < r)
{
int q = mutiply(a,p,r);
quicksort(a,p,q);
quicksort(a,q+1,r);
}
}
int main()
{
__int64 ans,maxx = 0;int t = 1;
for(int i = 0 ; i<= 31 ;i++)//计算ans = 2^i*3^j*5^k*7^l的每一个数.即为满足条件的数.最后再2排序就OK了.
{
for(int j = 0 ; j <= 31 ; j++)
{
for(int k = 0 ; k <= 31 ; k++)
{
for(int l = 0 ; l <= 31 ; l++)
{
bool vis = 0;
ans = 1;
for(int ss = 0 ; ss < i ; ss++)
{
ans *= 2;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < j ; ss++)
{
ans *= 3;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < k ; ss++)
{
ans *= 5;
if(ans > 2000000000)
vis = 1;
}
for(int ss = 0 ; ss < l ; ss++)
{
ans *= 7;
if(ans > 2000000000)
vis = 1;
}
if(!vis)
{
a[t++] = ans;
}
else break;
}
}
}
}
quicksort(a,1,t-1);
int n;
while(scanf("%d",&n) && n!= 0)
{
if((n % 10 == 1 || n % 10 == 2 || n % 10 == 3 ) && n/10%10 == 1)
printf("The %dth humble number is %I64d.\n",n,a[n]);
else
{
if(n % 10 == 3)
printf("The %drd humble number is %I64d.\n",n,a[n]);
if(n % 10 == 2)
printf("The %dnd humble number is %I64d.\n",n,a[n]);
if(n % 10 == 1)
printf("The %dst humble number is %I64d.\n",n,a[n]);
if(n % 10 != 3 && n % 10 != 2 && n % 10 != 1)
printf("The %dth humble number is %I64d.\n",n,a[n]);
}
}
}