Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我觉得我写得漂亮,嘿嘿

Posted by ACong at 2009-04-30 16:11:29 on Problem 2247
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator