fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int N = 1e6;
  4.  
  5. bool prime_poo(long long prime){
  6. if (prime <= 1)return false;
  7. for (long long p = 2; p < prime; p++){
  8. if (prime % p == 0){
  9. return false;
  10. }
  11. }
  12. return true;
  13. }
  14.  
  15. signed main(){
  16. ios::sync_with_stdio(false);
  17. freopen("SODER.INP","r",stdin);
  18. freopen("SODER.OUT","w",stdout);
  19.  
  20. long long n, a[N];
  21. string s;
  22. cin >> n;
  23. for (long long i = 0; i < n; i++){
  24. cin >> a[i];
  25. long long b = a[i];
  26. while(b > 0){
  27. if (prime_poo(b) == false){
  28. break;
  29. }
  30. else if (b/10 == 0){
  31. cout << a[i];
  32. if (i+1 != n){
  33. cout << endl;
  34. }
  35. break;
  36. }
  37. else {
  38. b/=10;
  39. }
  40. }
  41. }
  42. }
  43.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty