标签:blog desc tor humble numbers idg orm des min
1 #include<stdio.h> 2 int f[6000]; 3 int min(int a,int b) 4 { 5 if(a<b)return a; 6 else return b; 7 } 8 int main() 9 { 10 int i,a,b,c,d,n; 11 f[1]=1; 12 a=b=c=d=1; 13 for(i=2;i<=5842;i++) 14 { 15 f[i]=min(f[a]*2,min(f[b]*3,min(f[c]*5,f[d]*7))); 16 if(f[i]==f[a]*2)a++; 17 if(f[i]==f[b]*3)b++; 18 if(f[i]==f[c]*5)c++; 19 if(f[i]==f[d]*7)d++; 20 } 21 while(scanf("%d",&n),n) 22 { 23 if(n%10==1&&n % 100!=11)printf("The %dst humble number is %d.\n",n,f[n]); 24 else 25 if(n%10==2&&n % 100!=12)printf("The %dnd humble number is %d.\n",n,f[n]); 26 else 27 if(n%10==3&&n % 100!=13)printf("The %drd humble number is %d.\n",n,f[n]); 28 else 29 printf("The %dth humble number is %d.\n",n,f[n]); 30 } 31 return 0; 32 }
标签:blog desc tor humble numbers idg orm des min
原文地址:http://www.cnblogs.com/123tang/p/6056201.html