fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define task "DPRIME3"
  4. #define ll long long int
  5. #define pb push_back
  6. #define el "\n"
  7. #define vpll vector<pair<ll, ll>>
  8. #define vll vector<long long>
  9. #define pii pair<int, int>
  10. #define pqll priority_queue
  11. const ll N = 1e6 + 2;
  12. const ll MOD = 1e9 + 7;
  13. const ll INF = 1e5;
  14. ll n, x, y, z;
  15. vector<bool> f(MOD, 1);
  16. void tassk(){
  17. ios_base::sync_with_stdio(0);
  18. cin.tie(0);
  19. cout.tie(0);
  20. if (fopen(task".inp","r"))
  21. {
  22. freopen(task".inp","r",stdin);
  23. freopen(task".out","w",stdout);
  24. }
  25. }
  26. void solve() {
  27. f[0] = f[1] = 0;
  28. cin >> n;
  29. for (int i = 2; i <= sqrt(n); i++){
  30. if (f[i]){
  31. for (int j = i * i; j <= n; j += i){
  32. f[j] = 0;
  33. }
  34. }
  35. }
  36. ll dem = 0;
  37. for (int y = 3; y <= sqrt(n - 4); y++){
  38. if (f[y]){
  39. z = y * y + 4;
  40. if (f[z]){
  41. cout << 2 << " " << y << " " << z << el;
  42. dem++;
  43. }
  44. }
  45. }
  46. if (dem == 0) cout << -1;
  47. }
  48. int main()
  49. {
  50. tassk();
  51. solve();
  52. return 0;
  53. }
  54.  
Success #stdin #stdout 0.02s 125340KB
stdin
Standard input is empty
stdout
-1