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

内存限制是65536K,计算一下就知道了

Posted by RoBa at 2006-05-03 13:40:06 on Problem 2262
In Reply To:Re:怎样减少运行时间? 看来只能先建立一个素数表,用内存换时间了…… Posted by:linandmin at 2006-05-03 01:31:51
> 这是我的代码,Sample没过,照样也敢交。然后OJ给了个Rumtime Error。
> 本来是不敢交的,看到楼下xfxyjwy兄的代码中开了个number[1000001]的数组,才鼓起勇气交上去的。
> 弄不明白了,难道xfxyjwy兄开了这么大的数组却能过吗?
> #include<stdio.h>
> #define N 1000001
> 
> bool number[N]={0};
> 
> void compute_prime()
> {
> 	int i,j;
> 	for(i=2;i<N;i++)
> 		if(number[i]==0)
> 			for(j=i;i*j<N;j++)
> 				number[i*j]=true;
> }
> 
> int main()
> {
> 	int n,i;
> 	compute_prime();
> 	while(scanf("%d",&n))
> 	{
> 		if(n==0)	break;
> 		for(i=2;i<N;i++)
> 			if(!number[i] && !number[n-i])
> 			{
> 				printf("%d = %d + %d\n",n,i,n-i);
> 				break;
> 			}
> 	}
> 	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