fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_LENGTH = 100;
  5. const int THOUSAND = 1000;
  6. const int HUNDRED = 100;
  7. const int TEN = 10;
  8.  
  9. int main() {
  10. int n, v[MAX_LENGTH + 1];
  11. cin >> n;
  12.  
  13.  
  14. for (int i = 1; i <= n; ++i) {
  15. int groups = 0;
  16. cin >> v[i];
  17. int copyEl = v[i];
  18. int primeGroup = 0;
  19. while (copyEl) {
  20. if (copyEl < 0) {
  21. copyEl *= -1;
  22. }
  23. int triplets = 1;
  24. if (copyEl % THOUSAND >= HUNDRED) {
  25. ++groups;
  26. triplets = copyEl % THOUSAND;
  27. //cout << copyEl % THOUSAND <<"\n";
  28. // cout << triplets <<"\n";
  29. }
  30. int flag = 1;
  31. //primeGroup = 0;
  32. //cout << triplets <<"\n";
  33. for (int div = 2; div < triplets; ++div) {
  34. if (triplets % div == 0) {
  35. flag = 0;
  36. }
  37. }
  38. if (flag == 1 && triplets > 1) {
  39. ++primeGroup;
  40. }
  41. copyEl /= TEN;
  42. }
  43. if (primeGroup >= 2 && groups >= 2) {
  44. cout << v[i] <<" ";
  45. }
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5312KB
stdin
5
5471499 11331 3372 117 -38383

6
5471499 11331 3372 117 -38383 1300012

1
5471499



5
5471499 11331 3372 117 -38383
stdout
5471499 11331 -38383