| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大牛们看看我的程序吧,为什么总wa
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator