This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_1_C"
#include "../../../template/template.hpp"
#include "../../../math/eratosthenes.hpp"
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
range_eratosthenes ss(1, 100000010);
int n;
cin >> n;
int ans = 0;
rep(i, n){
int a; cin >> a;
if(ss.is_prime(a)) ans++;
}
cout << ans << "\n";
}
#line 1 "test/aoj/ALDS1/ALDS1_1_C.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_1_C"
#line 1 "template/template.hpp"
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#include <climits>
#include <functional>
#include <cassert>
#include <numeric>
#include <cstring>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define per(i, n) for(int i = (n) - 1; i >= 0; i--)
using ll = long long;
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
constexpr int mod = 1000000007;
using namespace std;
template<class T, class U>
bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; }
template<class T, class U>
bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; }
#line 4 "test/aoj/ALDS1/ALDS1_1_C.test.cpp"
#line 1 "math/eratosthenes.hpp"
struct range_eratosthenes {
private:
ll L,R,M;
static constexpr int Max_range = 100000010; //10^8
bitset<Max_range> small, large;
public:
range_eratosthenes(const ll L, const ll R) : L(L), R(R), M(sqrt(R)+1){
assert(M <= Max_range && R - L <= Max_range);
for(ll i = 2; i < M; i++){
if(small[i]) continue;
for(ll j = i+i; j < M; j += i) small[j] = 1;
for(ll j = max(2LL, (L+i-1)/i)*i; j < R; j += i)
large[j - L] = 1;
}
}
bool is_prime(const ll n) const{
assert(L <= n && n < R);
return !large[n - L];
}
};
#line 6 "test/aoj/ALDS1/ALDS1_1_C.test.cpp"
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
range_eratosthenes ss(1, 100000010);
int n;
cin >> n;
int ans = 0;
rep(i, n){
int a; cin >> a;
if(ss.is_prime(a)) ans++;
}
cout << ans << "\n";
}