-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
131 lines (112 loc) · 3.19 KB
/
A.cpp
File metadata and controls
131 lines (112 loc) · 3.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//__________Includes__________________//
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <map>
# include <unordered_map>
# include <set>
# include <unordered_set>
# include <bitset>
# include <queue>
# include <stack>
# include <complex>
# include <cmath>
# include <climits>
# include <cstring>
//____________Containers_Define__________//
# define vi vector<int>
# define vll vector<long long>
# define vull vector<unsigned long long>
# define vvi vector<vector<int> >
# define vvll vector<vector<long long> >
# define vvull vector<vector<unsigned long long> >
# define vs vector<string>
# define vvs vector<vector<string> >
# define pii pair<int, int>
# define pis pair<int, string>
# define psi pair<string, int>
# define mpii map<int, int>
# define mpis map<int, string>
# define mpsi map<string, int>
# define mpiv map<int, vector<int> >
# define umpii unordered_map<int, int>
# define umpis unordered_map<int, string>
# define umpsi unordered_map<string, int>
# define umpiv unordered_map<int, vector<int> >
//_____________Data_type________________//
# define ll long long
# define ull unsigned long long
# define string str
//_____________Methods__________________//
# define mp make_pair
# define pb push_back
# define pf push_front
# define f first
# define s second
using namespace std;
//______________Functions________________//
bool isInt(double d)
{
return ((double)(int)d - d == (double)0.00);
}
ull fact(ull n)
{
ull res = 1;
while (n--) res *= (n + 1);
return (res);
}
ull C(ull n, ull k)
{
vull dpp(n + 1);
vvull dp(k + 1, dpp);
for (int i=1; i<=n; i++) dp[1][i] = i;
for (int i=2; i<=k; i++)
{
for (int j=1; j<=n; j++)
{
if (i > j)
dp[i][j] = 0;
else
dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
}
}
return (dp[k][n]);
}
bool is_prime(long long nbr)
{
long long _sq = sqrtl(nbr);
if (nbr == 2)
return (true);
if (nbr < 2 || (!(nbr % 2)))
return (false);
for (long long i = 3; i <= _sq; i += 2)
if (!(nbr % i))
return (false);
return (true);
}
void solve()
{
int n;
ull count = 0;
cin >> n;
for (int i=1; i<=n; i++)
{
int c = 0;
for (int j=2; j<=(int)(i / 2); j++)
{
if (is_prime(j))
c += !(i % j);
}
count += (c == 2);
}
cout << count << endl;
}
int main()
{
int cases = 1;
//cin >> cases;
while (cases--)
solve();
return (0);
}