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

要崩溃了,为什么是WA?

Posted by mcacm at 2008-08-19 00:51:16 on Problem 1411
#include<stdio.h>
#define SIZE 1000
typedef struct
{
	int x,y;
	int number;
}NNN;
int n[SIZE];
int m[SIZE]={2};
int Count()
{
	int i,j;
	int num=0;
	for(i=3;i<SIZE;i+=2)
	{
		if(n[i]==0)
			m[++num]=i;
		for(j=1;j<=num&&i*m[j]<=SIZE;j++)
			n[i*m[j]]=1;
	}
	return num;
}
int main()
{
	int a,b,c;
	int i,j,k;
	int num;
	NNN stat[SIZE];
	int max;

	num=Count();
	while(scanf("%d%d%d",&a,&b,&c)==3)
	{
		if(a==0&&b==0&&c==0)
			break;
		k=0;
		for(i=num;i>=0;i--)
		{
			for(j=i;j>=0;j--)
			{
				if((double)m[j]/m[i]>=(double)b/c&&m[j]*m[i]<=a)
				{
					stat[k].x=m[j];
					stat[k].y=m[i];
					stat[k].number=m[i]*m[j];
					k++;
					break;
				}
			}
		}
		max=0;
		for(i=1;i<k;i++)
		if(stat[max].number<stat[i].number)
				max=i;
		printf("%d %d\n",stat[max].x,stat[max].y);
	}
	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