fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool p[10000019];
  5.  
  6. int main(){
  7.  
  8. ios::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11.  
  12. memset(p, 1, sizeof p);
  13. for(long long i = 2; i <= 10000009; ++i){
  14. if(p[i]){
  15. for(long long j = i * i; j <= 10000009; j += i)
  16. p[j] = 0;
  17. }
  18. }
  19. int n;
  20. while(cin >> n){
  21. bool found = false;
  22. int i, j, k;
  23. for(i = 2; i <= 3; ++i){
  24. for(j = 2; j <= 3; ++j){
  25. for(k = 2; k <= 3; ++k){
  26. if(n - i - j - k >= 2){
  27. if(p[n - i - j - k]){
  28. found = true;
  29. break;
  30. }
  31. }
  32. }
  33. if(found)
  34. break;
  35. }
  36. if(found)
  37. break;
  38. }
  39. if(found)
  40. cout << i << " " << j << " " << k << " " << n - i - j - k << '\n';
  41. else
  42. cout << "Impossible.\n";
  43. }
  44. return 0;
  45. }
Success #stdin #stdout 0.09s 13204KB
stdin
24
36
46
stdout
2 2 3 17
2 2 3 29
3 3 3 37