fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. const int MAXA = 1000000;
  7. int sum_div[MAXA + 5];
  8.  
  9. int main() {
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(NULL);
  12.  
  13. for (int i = 1; i <= MAXA; ++i) {
  14. for (int j = i * 2; j <= MAXA; j += i) {
  15. sum_div[j] += i;
  16. }
  17. }
  18.  
  19. return 0;
  20.  
  21. int n;
  22. if (cin >> n) {
  23. vector<int> res;
  24. for (int i = 0; i < n; ++i) {
  25. int x;
  26. cin >> x;
  27. if (sum_div[x] > x) {
  28. res.push_back(x);
  29. }
  30. }
  31.  
  32. cout << res.size() << "\n";
  33. for (int i = 0; i < (int)res.size(); ++i) {
  34. cout << res[i] << (i == (int)res.size() - 1 ? "" : " ");
  35. }
  36. cout << "\n";
  37. }
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.04s 7396KB
stdin
1 998244353
stdout
Standard output is empty