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 |
水题100道留念!!!#include<stdio.h> #define MAX 1000001 int prime[MAX]={0}; void sushu() { int i,j; for(i=2;i<MAX;i++) if(!prime[i]) for(j=2;i*j<MAX;j++) prime[j*i]=1; prime[0] = prime[1] = 1; } int main() { int n,i; sushu(); while (scanf("%d",&n)==1,n) { for(i=3;i<=n/2;i+=2) if(prime[i]==0&&prime[n-i]==0) { printf("%d = %d + %d\n", n, i, n-i); break; } if(i>n/2) printf("Goldbach's conjecture is wrong.\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator