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 dengwenbing2012 at 2011-07-28 08:57:01 on Problem 2262
#include"stdio.h"
#include"math.h"
int shusu(int x);
main()
{
	int n;
	int i,j,z;

	A:	while(scanf("%d",&n)&&n)
		{
		for(i=1;i<n/2;i++)
			for(j=i;j<n;j++)
			{
				if((shusu(i)&&shusu(j))&&(i+j==n)&&(i!=1)&&(i%2!=0))
				{
					printf("%d = %d + %d\n",n,i,j);
					goto A;
				}
			}

		}
}
int shusu(int x)
{
	int flag=1;
	int i;
	for(i=2;i<=sqrt(x);i++)
	{
		if(x%i==0)
		{
			flag=0;
			break;
		}
	}
	return flag;
}

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