/* 题目大意: 素数因子只能是2,3,5,7. 思路: 将解保存在humble数组里面,由于数组里素数因子只有2,3,5,7。则再乘以2,3,5,7 则不变,输出考验英语水平。 */ #include<iostream> #include<cstring> using namespace std; int mi(int a,int b) { return (a<b?a:b); } int humble[6000]={0}; int main() { humble[0]=1; int p1=0,p2=0,p3=0,p4=0,index=1; int t1,t2,t3,t4; int x; while (index<5843) { t1=humble[p1]*2; t2=humble[p2]*3; t3=humble[p3]*5; t4=humble[p4]*7; int t=mi(mi(t1,t4),mi(t2,t3)); humble[index++]=t; if (t==t1) ++p1; if (t==t2) ++p2; if (t==t3) ++p3; if (t==t4) ++p4; } while(cin>>x&&x) { cout<<"The "<<x; if(x%10==1&&x%100!=11) cout<<"st"; else if(x%10==2&&x%100!=12) cout<<"nd"; else if(x%10==3&&x%100!=13) cout<<"rd"; else cout<<"th"; cout<<" humble number is "; printf("%d.\n",humble[x-1]); } return 0; }