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 08161072 at 2008-11-26 17:53:02 on Problem 2262
#include"stdio.h"

#include"math.h"
#define N 1000000
main()
{
      int a[N+1];
      int i,j,k;
      int x;
     
      a[0]=a[1]=0;
      for(i=2;i<=N;i++)
          a[i]=1;
      for(i=2;i<=sqrt(N);i++)
           if( a[i] )
          {    
               for(k=i+i;k<=N;k+=i)
                   a[k]=0;
           }  
   
      scanf("%d",&x);
         
while(x!=0)
{
      for(i=2;i<x/2;i++)
        if(a[i]&&a[x-i]) 
       { printf("%d =  %d + %d\n",x,i,x-i);break;}
       if(i==x/2)printf("Goldbach's conjecture is wrong.\n");
      scanf("%d",&x);
}
      

}

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