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

提交N+1次了,老是RE,哪位大哥大姐帮小弟看看啊,感激不尽~~~

Posted by ZNOBODY at 2008-08-16 15:23:59 on Problem 2262 and last updated at 2008-08-16 16:36:12
#include <stdio.h>
#define MAX 1000001
bool t[MAX]={false};
void BuildPrime(){
	long i,j;
	for(i=2;i<MAX;i++){
		if(t[i]==false)
			for(j=i;i*j<MAX;j++)
				t[i*j]=true;
	}
	t[0]=t[1]=t[2]=true;
}
int main(){
	long n,c,l;
	BuildPrime();
	for(c=0;;c++){
		scanf("%ld",&n);
		if(n==0)
			break;
		for(l=1;l<=n;l++){
			if(!t[l]&&!t[n-l]){
				printf("%d = %d + %d\n",n,l,n-l);
				break;
			}
		}
		if(l==n+1)
			printf("Goldbach's conjecture is wrong.\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