Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- #include <set>
- #include <map>
- using namespace std;
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int n, m;
- cin >> n >> m;
- vector<long long>v(15485864);
- for (int i = 0; i <= 15485863; ++i) {
- v[i] = i;
- }
- for (int i = 0; i <= 15485863; ++i) {
- if (v[i] != 0) {
- for (int j = 2 * i; j <= 15485863; j += i)
- v[j] = 0;
- }
- }
- long long res = 0; int ptr = 0;
- for (int i = 2; ptr < m; ++ptr) {
- if (v[i] == 0) {
- continue;
- }
- if (ptr >= n)
- res += 1;
- }
- cout << res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement