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

AC代码附上

Posted by LXY5201314 at 2018-01-13 22:03:56 on Problem 2262
#include<stdio.h>
#include<math.h>
int prime_number(int a)
{
    int i;
    for(i=2;i<=sqrt(a);i++)
        if((a%i)==0)return 0;
    return 1;
}
int main(void)
{
    long int n,i,a;
    while(scanf("%ld",&n)!=EOF)
    {
        if(n==0)break;
        a=0;
        for(i=3;i<=n/2;i+=2)
        {
            if(prime_number(i)&&prime_number(n-i))
            {
                a=i;break;
            }
        }
        if(a)printf("%ld = %ld + %ld\n",n,a,n-a);
        else 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