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 |
AC代码附上#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator