模板——欧拉筛法
/************************************************ * Author :Powatr * Created Time :2015-8-17 10:52:03 * File Name :欧式筛法.cpp ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 1e5 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int N = 1e6+10; int prime[MAXN]; int check[MAXN]; int tot; void Eular()//O(n) { tot = 0; memset(check, 0, sizeof(check)); for(int i = 2; i <= N; i++){ if(!check[i]){ prime[tot++] = i; } for(int j = 0 ; j < tot; j++){ if(i*prime[j] > N) break; check[i*prime[j]] = 1; if(i%prime[j] == 0) break; } } }