View Code
#include"iostream"
using namespace std;
int prime(int x)
{
int i;
if(x%2==0&&x!=2) return 0; //此处剪枝可以提高效率,要不超时
for(i=3;i<=sqrt(x);i+=2)
{
if(x%i==0) return 0;
}
return 1;
}
int main()
{
int n,m;
int i;
while(cin>>n)
{
int count=0;
for(i=0; i<n; i++)
{
cin>>m;
if(prime(m)) count++;
}
cout<<count<<endl;
}
return 0;
}