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

Do you really think goldbach's conjecture is wrong when n == 6 ?

Posted by MicroGoogle at 2007-10-17 21:16:45 on Problem 2262
In Reply To:好心人帮我看看,哪里错了~~ Posted by:chenhaifeng at 2007-10-17 20:26:57
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> 
> #define Maxn 1000005
> 
> int prime[80000];
> bool f[Maxn];
> int pt;
> 
> void fact()
> {
>     int i, j;
>     pt = 0;
>     memset(f, false, sizeof(f));
>     for(i = 4;i <= 1000000;i += 2){
>         f[i] = true;
>     }
>     f[0] = f[1] = f[2] = true;
>     for(i = 3;i <= 1000000;i++){
>         if(f[i] == false){
>              prime[pt++] = i;
>              if(i > 1000)continue;
>              j = i * i;
>              while(j <= 1000000){
>                     f[j] = true;
>                     j += i;
>             }
>         }
>     }
> }
> 
> int main()
> {
>     fact();
>     int n, tag, i, a, b; 
>     while(scanf("%d", &n) && n){
>         tag = 0;
>         for(i = 0;i < pt;i++){
>             if(prime[i] >= n || n - prime[i] < prime[i]) break;
>             if(f[n - prime[i]] == false && n - prime[i] != prime[i]){
>                 a = prime[i];
>                 tag = 1;
>                 break;
>             }
>         }
>         if(tag == 0){
>             printf("Goldbach's conjecture is wrong.\n");
>             continue;
>         }
>         b = n - a;
>         printf("%d = %d + %d\n", n, a, b);
>     }
> }

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