-
Notifications
You must be signed in to change notification settings - Fork 0
/
cp1.cpp
47 lines (39 loc) · 937 Bytes
/
cp1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
int main(){
const int maxi = 1e5+5;
int n;
cin >> n;
for(int i=1; i<n; i++) {
int count = 0;
if(is_almost_prime(i)) {
count++;
}
cout << count << endl;
}
bool is_almost_prime(int n) {
int lim = sqrt(n);
for(int i=1; i<=lim; i++){
if(n%i==0){
if(i!= n/i && isprime[i] == 1 && isprime[n/i] == 1){
return true;
}
else{
return false;
}
}
}
}
int isprime[maxi] = {-1};
bool is_prime(int n) {
int lim1 = sqrt(n);
for(int i=2; i<= lim1; i++){
if(n%i==0){
isprime[n] = 0;
}
}
if(isprime[n] == -1){
isprime[n] = 1;
}
}
}