Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14343 Accepted Submission(s): 6229
1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 /*策略打表实现存储*/ 5 __int64 sav[10000]; 6 int cmp(void const *a,void const *b) 7 { 8 return (*(__int64 *)a)-(*(__int64 *)b); 9 } 10 int work() 11 { 12 __int64 a,b,c,d,aa,bb,cc,dd; 13 int cnt=0; 14 for(a=0,aa=1; ;a++) 15 { 16 if(a!=0) aa*=7; 17 if(aa>2000000000) break; 18 for(b=0,bb=1; ; b++) 19 { 20 if(b!=0) bb*=5; 21 if((aa*bb)>2000000000) break; 22 for(c=0,cc=1; ; c++) 23 { 24 if(c!=0)cc*=3; 25 if((aa*bb*cc)>2000000000) break; 26 for(d=0,dd=1; ;d++) 27 { 28 if(d!=0) dd*=2; 29 if((aa*bb*cc*dd)>2000000000) break; 30 sav[cnt++]=(aa*bb*cc*dd); 31 } 32 } 33 } 34 } 35 36 return cnt; 37 } 38 int main() 39 { 40 int n; 41 qsort(sav,work(),sizeof(sav[0]),cmp); 42 while(scanf("%d",&n),n) 43 { 44 int tem=n%100; 45 printf("The "); 46 if(tem>10&&tem<20) 47 printf("%dth ",n); 48 else 49 { 50 tem%=10; 51 if(tem==1) 52 printf("%dst ",n); 53 else if(tem==2) 54 printf("%dnd ",n); 55 else if(tem==3) 56 printf("%drd ",n); 57 else 58 printf("%dth ",n); 59 } 60 printf("humble number is %I64d.\n",sav[n-1]); 61 } 62 return 0; 63 }