-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlmostprime.cpp
More file actions
54 lines (45 loc) · 1.07 KB
/
Almostprime.cpp
File metadata and controls
54 lines (45 loc) · 1.07 KB
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
48
49
50
51
52
#include "bits/stdc++.h"
#include <cstdint>
#include <cstdio>
#define F first
#define S second
#define PG push_back
#define PPB pop_back
#define PF push_front
#define MP make_pair
#define REP0(i,a,b) for (int i = a; i < b; i++)
#define REP1(i,a,b) for (int i = a; i <= b; i++)
#define PPC __builtin_popcount
#define PPCLL __builtin_popcountll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const ll INF = 1e18;
const int32_t M = 1e9+7;
const int32_t MM=998244353;
vi sieve;
int solve(int n){
sieve = vi(n+1,0);
for(int i = 2; i <=n; i++){
if(sieve[i] == 0){
for(int j = 2*i; j<=n; j+=i){
sieve[j] += 1;
}
}
}
int count = 0;
REP1(i,0,n){
if(sieve[i] == 2){
count++;
}
}
return count;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
printf("%d\n",solve(n));
}