fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. bool checkBit (ll num, ll bit)
  6. {
  7. return ((num >> bit) & 1);
  8. }
  9.  
  10. void solve()
  11. {
  12. int n; cin >> n;
  13. vector<int> F;
  14. vector<int> F2;
  15. for (int i = 0; i < n; ++i)
  16. {
  17. int x; cin >> x;
  18. if (16112024 % x == 0 && x != 2)
  19. F.push_back(x);
  20. if (x == 2)
  21. F2.push_back(2);
  22. }
  23. sort(F.begin(), F.end());
  24. F.erase(unique(F.begin(), F.end()), F.end());
  25. for (int i = 0; i < min(int(F2.size()), 3); ++i)
  26. F.push_back(2);
  27. int mask = (1<<F.size())-1;
  28. for (int bit = mask; bit >= 0; --bit)
  29. {
  30. ll mul = 1;
  31. vector<int> ans;
  32. for (int i = 0; i < F.size(); ++i)
  33. if (checkBit(bit, i))
  34. {
  35. mul *= F[i];
  36. ans.push_back(F[i]);
  37. }
  38. if (mul == 16112024)
  39. {
  40. cout << ans.size() << '\n';
  41. for (auto&o:ans)
  42. cout << o << ' ';
  43. return;
  44. }
  45. }
  46. cout << 0;
  47. }
  48.  
  49. int main()
  50. {
  51. #ifndef ONLINE_JUDGE
  52. freopen("input.txt", "r", stdin);
  53. freopen("output.txt", "w", stdout);
  54. freopen("Errors.txt", "w", stderr);
  55. #endif
  56. ios_base::sync_with_stdio(false);
  57. cin.tie(nullptr);
  58. cout.tie(nullptr);
  59. int t = 1;
  60. // cin >> t;
  61. while (t--)
  62. {
  63. solve();
  64. if (t) cout << '\n';
  65. }
  66. cout << '\n';
  67. return 0;
  68. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0