Saleh127

uva 543.cpp

Jun 8th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  5. #define maX 1000002
  6. bool pm[maX];
  7. void sieve()
  8. {
  9. pm[2]=false;
  10. for(ll i=4;i<=1000000;i+=2)
  11. {
  12. pm[i]=true;
  13. }
  14. for(ll i=3;i<=1000000;i+=2)
  15. {
  16. if(!pm[i])
  17. {
  18. for(ll j=i*i;j<=1000000;j+=i+i)
  19. {
  20. pm[j]=true;
  21. }
  22. }
  23. }
  24. pm[0]=pm[1]=true;
  25. }
  26. int main()
  27. {
  28. Faster
  29. sieve();
  30. ll a;
  31. while(cin>>a && a)
  32. {
  33. for(ll i=2;i<=a;i++)
  34. {
  35. ll c=a-i;
  36. if(pm[i]==false && pm[c]==false)
  37. {
  38. printf("%lld = %lld + %lld\n",a,i,c);
  39. break;
  40. }
  41. }
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment