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

为什么数据都过,但是RE呢?高手帮忙谢谢

Posted by ttbobo at 2009-08-04 02:38:32 on Problem 2262
#include <stdio.h>

#include <string.h>
#define maxn 1001000
int a[maxn],t1,t2;
void deal(int x)
{
    int i,j;
    i=x;
    j=1;
    while (i*j<=maxn)
    {
		j++;
		a[i*j]=1;
	}
}
int main()
{
	int i,j;
	a[1]=1;a[2]=0;
	memset(a,0,sizeof(a)) ;
	for (i=2;i<=maxn;i++)
	   {
			if (a[i]==0) deal(i);
		}
	a[2]=1;
	while (scanf("%d",&t1)!=EOF && t1!=0)
	{
		t2=0;
		if (t1%2==1) {printf("Goldbach's conjecture is wrong.\n" );t2=1;}
		else 
		for (i=3;i<=t1/2;i++)
		{
			if (a[i]==0 && a[t1-i]==0)
			  {
					printf("%d = %d + %d\n",t1,i,t1-i);
					t2=1;
					break;
			  }
		}
		if (t2 ==0) printf("Goldbach's conjecture is wrong.\n" );
	}
	return 1;
}

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