How many prime numbers
Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 14684 Accepted Submission (s): 5091
Problem Description Give you a lot of positive integers, just to find out how many prime numbers there is.
Input There is a lot of cases. In each case, there is a integer N representing the number of integers to find. Each of the integer won ' t exceed 32-bit signed integer, and each of the them won ' t is less than 2.
Output for each case, print the number of prime numbers you has found out.
Sample Input32 3 4
Sample Output2
Exercises
Water violence, play table not, because the data volume is too large, run to sqrt (x) can;
Code:
#include <cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespacestd;BOOLjsintx) { if(x==2)return true; if(x==1|| x==0)return false; if(%2==0)return false; for(intI=3; i<=sqrt (x); i+=2){ if(x%i==0)return false; } return true;}intMain () {intN,a; while(~SCANF ("%d",&N)) { intCnt=0; for(intI=0; i<n;i++) {scanf ("%d",&a); if(JS (a)) cnt++; } printf ("%d\n", CNT); } return 0;}
How many prime numbers (number of counts)