-
Notifications
You must be signed in to change notification settings - Fork 1
/
11423.cpp
54 lines (45 loc) · 1003 Bytes
/
11423.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
48
49
50
51
52
53
54
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <bitset>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using iis = pair<int, string>;
using ii64 = pair<i64, i64>;
using iii = tuple<int, int, int>;
bool check[10000005];
int sum[10000005];
int main() {
for (int i = 2; i * i <= 10000005; i++)
{
if (check[i])
continue ;
for (int j = (i * 2); j <= 10000005 ; j += i)
check[j] = true;
}
for (int i = 2; i <= 10000005; i++)
{
sum[i] += sum[i - 1];
if (!check[i])
sum[i] ++;
}
int n, m;
while (cin >> n >> m) {
cout << sum[m] - sum[n-1] << "\n\n";
}
return 0;
}