#P3383. 【模板】线性筛素数

    ID: 1847 远端评测题 3000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学O2优化素数判断,质数,筛法

【模板】线性筛素数

Description

Given an upper bound nn and qq queries, for each query output the kk-th smallest prime number.

Input Format

The first line contains two positive integers n,qn, q, representing the query range and the number of queries.

Each of the next qq lines contains a positive integer kk, asking for the kk-th smallest prime.

Output Format

Output qq lines, each containing a single integer as the answer.

100 5
1
2
3
4
5
2
3
5
7
11

Hint

Constraints
For 100%100\% of the testdata, n=108n = 10^8, 1q1061 \le q \le 10^6, and it is guaranteed that the requested primes do not exceed nn.

Data by NaCly_Fish.

Translated by ChatGPT 5