#include #include #include struct Sieve { std::vector min_factor, prime; Sieve(int n) { min_factor.resize(n + 1, 0); for (int i = 2; i <= n; ++i) { if (min_factor[i] == 0) { min_factor[i] = i; prime.push_back(i); } for (int x : prime) { if (x * i > n || x > i) break; min_factor[x * i] = x; } } } std::vector> prime_factor(int n) { std::vector> res; while (n > 1) { if (res.empty() || res.rbegin()->first != min_factor[n]) { res.emplace_back(min_factor[n], 1); } else ++res.rbegin()->second; n /= min_factor[n]; } return res; } void divisor_dfs(std::vector> &p, int t, int cur, std::vector &res) { if (cur == (int)p.size()) { res.push_back(t); return; } divisor_dfs(p, t, cur + 1, res); for (int _ = 0; _ < p[cur].second; ++_) { t *= p[cur].first; divisor_dfs(p, t, cur + 1, res); } } std::vector get_divisor(int n, bool sorted = false) { std::vector res; auto p = prime_factor(n); divisor_dfs(p, 1, 0, res); if (sorted) sort(res.begin(), res.end()); return res; } }; #include #include #include template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; } template T div_floor(T a, T b) { if (b < 0) a *= -1, b *= -1; return a >= 0 ? a / b : (a + 1) / b - 1; } template T div_ceil(T a, T b) { if (b < 0) a *= -1, b *= -1; return a > 0 ? (a - 1) / b + 1 : a / b; } template struct CoordComp { std::vector v; bool sorted; CoordComp() : sorted(false) {} int size() { return v.size(); } void add(T x) { v.push_back(x); } void build() { std::sort(v.begin(), v.end()); v.erase(std::unique(v.begin(), v.end()), v.end()); sorted = true; } int get_idx(T x) { assert(sorted); return lower_bound(v.begin(), v.end(), x) - v.begin(); } T &operator[](int i) { return v[i]; } }; #define For(i, a, b) for (int i = (int)(a); (i) < (int)(b); ++(i)) #define rFor(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); --(i)) #define rep(i, n) For(i, 0, n) #define rrep(i, n) rFor(i, n, 0) #define fi first #define se second using namespace std; using lint = long long; using pii = pair; using pll = pair; int main() { Sieve sv(100010); int t; scanf("%d", &t); rep(tt, t) { int n; scanf("%d", &n); printf("%ld\n", upper_bound(sv.prime.begin(), sv.prime.end(), n) - sv.prime.begin()); } }