Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define nmax 1000001
- bool v[nmax] ={} ;
- void ciur()
- {
- v[0] = v[1] = 1 ;
- for(int i = 4 ; i <= nmax ; i +=2)
- v[i] = 1 ;
- for(int i = 3 ; i <= nmax ; i += 2)
- if(v[i] == 0)
- for(int j = i ; j <= (nmax / i) ; ++ j)
- v[j * i] = 1 ;
- }
- int main()
- {
- int n , counter = 0 , a[nmax] ;
- ciur() ;
- cin >> n ;
- for(int i = 1 ; i <= n ; ++ i)
- {
- cin >> a[i] ;
- if(v[a[i]] == 0) counter ++ ;
- }
- cout << counter ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement