fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int N[1000001];
  8.  
  9. int main() {
  10. ios::sync_with_stdio(0);
  11. cin.tie(0);cout.tie(0);
  12. int n;
  13. bool goldbach = false;
  14. while(1)
  15. {
  16. if(n==0)
  17. break;
  18. goldbach = false;
  19. cin>>n;
  20. for(int i = 2;i<=n;i++)
  21. {
  22. N[i]=i;
  23. if(i!=2&&i%2==0)
  24. {
  25. N[i]=0;
  26. }
  27. if(i!=3&&i%3==0)
  28. {
  29. N[i]=0;
  30. }
  31. }
  32. for(int i = 2;i<=n;i++)
  33. {
  34. if(N[i]!=0)
  35. if(N[n-i]!=0)
  36. {
  37. cout<<n<<" "<<'='<<" "<<i<<" "<<'+'<<" "<<n-i<<"\n";
  38. goldbach = true;
  39. break;
  40. }
  41.  
  42. }
  43. if(goldbach==false&&n!=0)
  44. cout<<"Goldbach's conjecture is wrong."<<"\n";
  45.  
  46. }
  47. }
Success #stdin #stdout 0.01s 5280KB
stdin
10000
0
stdout
10000 = 3 + 9997