Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我觉得我写得漂亮,嘿嘿In Reply To:好像没错 Posted by:00448247 at 2009-04-08 19:00:15 #include <string.h> #include <algorithm> #include <iostream> using namespace std; #define MAX 5843 int min(int a,int b,int c,int d) { int min; min = a<b?a:b; min = min<c?min:c; return min<d?min:d; } int main() { int a[MAX]; char x,y; int i,n; int big_2=1,big_3=1,big_5=1,big_7=1; a[1]=1; for(i=2;i<MAX;i++) { a[i] = min(a[big_2]*2,a[big_3]*3,a[big_5]*5,a[big_7]*7); if(a[i] == a[big_2]*2) big_2++; if(a[i] == a[big_3]*3) big_3++; if(a[i] == a[big_5]*5) big_5++; if(a[i] == a[big_7]*7) big_7++; } while(scanf("%d",&n)!=EOF && n!=0) { if(n%100>=11 && n%100<=19) x='t',y='h'; else if(n%10==1) x='s',y='t'; else if(n%10==2) x='n',y='d'; else if(n%10==3) x='r',y='d'; else x='t',y='h'; printf("The %d%c%c humble number is %d.\n",n,x,y,a[n]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator