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

Re:水题100道留念!!!

Posted by wucheng_xidian at 2012-08-24 10:43:55 on Problem 2262
In Reply To:水题100道留念!!! Posted by:H3100402061 at 2011-06-04 19:20:40
> #include<stdio.h> 
> #define MAX 1000001 
> int prime[MAX]={0};  
> void sushu() 
> { 
>     int i,j; 
>     for(i=2;i<MAX;i++) //i只用循环到sqrt(MAX)
>         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:
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