Morass

G&E

Mar 3rd, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. int N,R,X;
  2. #define NO printf("%d is not the sum of two primes!\n",N);
  3. void pr(int a,int b){printf("%d is the sum of %s%d and %d.\n",N,a&1?"":"",a,b);}
  4. int main(void){
  5.     gen();
  6.     while(~scanf("%d",&N)){
  7.         if(N<5){NO continue;}
  8.         if(N&1){
  9.             if(IS((N-2)))NO
  10.             else pr(2,N-2);
  11.             continue;
  12.         }
  13.         R=(upper_bound(P,P+L,N>>1)-P-1),X=1;
  14.         if(P[R]*2==N)--R;
  15.         while(~R&&X){
  16.             if(!IS((N-P[R])))X=0,pr(P[R],N-P[R]);
  17.             --R;
  18.         }
  19.         if(X)NO;
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment