Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
/* QUANG VIP PRO */
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e7;
int n, cnt;
int a[1000100], snt[10000010];
map<long, long> f;
void sieve(){
for(int i = 2; i <= n; i++){
snt[i] = true;
}
for(int i = 2; i * i <= n; i++){
if(snt[i] = true){
for(int j = i * i; j <= n; j += i){
snt[j] = false;
}
}
}
}
int main(){
cin >> n;
sieve();
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= n; i++){
if(snt[a[i]] == true and f[a[i]] == 0){
cnt++;
f[a[i]]++;
}
}
cout << cnt;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
CÂU HỎI MỚI NHẤT
bài này làm kieue gì ạaa
32
835
18
xin 5 sao voi code vipp nhu nay dc co 4 sao v