标签:include humble numbers ram more std ret rip line
#include <iostream> #include <algorithm> #include <stdio.h> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <ctype.h> #define max_size 5843 using namespace std; long long num[max_size]; long long Min(long long a,long long b,long long c,long long d) { long long min1,min2; min1=a<b?a:b; min2=c<d?c:d; if(min1<min2) return min1; else return min2; } int main() { int i=1,p2,p3,p5,p7; p2=p3=p5=p7=1; num[1]=1; while(i<max_size) { num[++i]=Min(num[p2]*2,num[p3]*3,num[p5]*5,num[p7]*7); if(num[i]==num[p2]*2) p2++; if(num[i]==num[p3]*3) p3++; if(num[i]==num[p5]*5) p5++; if(num[i]==num[p7]*7) p7++; } int n; while(scanf("%d",&n)&&n) { if(n%10==1&&n%100!=11) printf("The %dst humble number is %lld.\n",n,num[n]); else if(n%10==2&&n%100!=12) printf("The %dnd humble number is %lld.\n",n,num[n]); else if(n%10==3&&n%100!=13) printf("The %drd humble number is %lld.\n",n,num[n]); else printf("The %dth humble number is %lld.\n",n,num[n]); } return 0; }
标签:include humble numbers ram more std ret rip line
原文地址:http://www.cnblogs.com/gonsedup/p/7262368.html