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 863784757 at 2011-07-22 10:06:44 on Problem 2247
#include<stdio.h>

#define min(a,b) ((a)<(b)?(a):(b))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
int main()
{
	int a[10000],n=1;
	int p2,p3,p5,p7;
	p2=p3=p5=p7=1;
	a[1]=1;
	while(a[n]<2000000000)
	{
		a[++n]=min4(2*a[p2],3*a[p3],5*a[p5],7*a[p7]);
		if(a[n]==2*a[p2]) p2++;
		if(a[n]==3*a[p3]) p3++;
		if(a[n]==5*a[p5]) p5++;
		if(a[n]==7*a[p7]) p7++;
	}
	while(scanf("%d",&n)&&n)
	{
		printf("The %d",n);
		if(n>10&&n<14)
		{
			if(n%10==1) printf("th");
			if(n%10==2) printf("th");
			if(n%10==3) printf("th");
		}
		else if(n%10==1||n%10==2||n%10==3)
		{
            if(n%10==1) printf("st");
			if(n%10==2) printf("nd");
			if(n%10==3) printf("rd");
		}		
		else
			printf("th");
		printf(" humble number is %d.\n",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