Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <stack>
- #include <cstring>
- #include <cmath>
- using namespace std;
- typedef long long ll;
- const int maxn = 1e6 + 10;
- bool is_prime[maxn];
- int main() {
- ios_base::sync_with_stdio(false);
- memset(is_prime, true, sizeof is_prime);
- is_prime[0] = false;
- is_prime[1] = false;
- for(ll i = 2; i <= maxn; i++) {
- if(is_prime[i]) {
- for(ll j = i * i; j <= maxn; j += i) {
- is_prime[j] = false;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment