标签:
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[5900]; int min1(int a,int b,int c,int d) { return min(min(min(a,b),c),d); } void inti() { int c1,c2,c3,c4; c1 = c2 = c3 = c4 = 1; a[1] = 1; for(int i = 2; i <= 5842; i++){ a[i] = min1(2*a[c1],3*a[c2],5*a[c3],7*a[c4]); if(a[i] == 2*a[c1]) c1++; if(a[i] == 3*a[c2]) c2++; if(a[i] == 5*a[c3]) c3++; if(a[i] == 7*a[c4]) c4++; } } int main() { inti(); int n; while(~scanf("%d",&n)&&n){ if(n%100 == 11 || n%100 == 12 || n % 100 == 13){ printf("The %dth humble number is %d.\n",n,a[n]); } else if(n%10 == 1){ printf("The %dst humble number is %d.\n",n,a[n]); } else if(n%10 == 2){ printf("The %dnd humble number is %d.\n",n,a[n]); } else if(n%10 == 3){ printf("The %drd humble number is %d.\n",n,a[n]); } else printf("The %dth humble number is %d.\n",n,a[n]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4539294.html