Farjana_akter

Untitled

Mar 13th, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define x 1000000
  4. bool mark[x+5]={false};
  5. void sieve()
  6. {
  7. int i,j,k=0,isprime[10000];
  8. mark[0]=true;
  9. mark[1]=true;
  10. for(i=2;i*i<=1000000;i++)
  11. {
  12. if(mark[i]==false)
  13. {
  14. for(j=i*i;j<=1000000;j+=i)
  15. {
  16. mark[j]=true;
  17. }
  18. }
  19. }
  20. }
  21. int main()
  22. {
  23. sieve();
  24. long long int n,i,j,k,a,b,c,d,e,f;
  25. while(cin>>n && n)
  26. {
  27. int flag=0;
  28. cout<<n<<":"<<endl;
  29. for(i=2;i<=(n/2);i++)
  30. {
  31. if(mark[i]==false)
  32. {
  33. a=n-i;
  34. if(mark[a]==false)
  35. {
  36. cout<<i<<"+"<<a<<endl;
  37. flag=1;
  38. break;
  39. }
  40. }
  41. }
  42. if(flag==0)
  43. cout<<"NO WAY!"<<endl;
  44. }
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment