fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int x,n,s = 0;
  5. cin >> n;
  6. for(int i = 1;i <= n;i++){
  7. cin >> x;
  8. if(x < 2) {
  9. continue;
  10. }
  11. bool check = true;
  12. for(int j = 2;j <= sqrt(x);j++){
  13. if(x % j == 0 && x/j > 1){
  14. check = false;
  15. break;
  16. }
  17. }
  18. if(check == true){
  19. s++;
  20. }
  21. }
  22. cout << s;
  23. }
  24.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
1 2 3 -4 5
stdout
3