P6421 [COCI 2008/2009 #2] RESETO
Description
The Sieve of Eratosthenes is a well-known method for finding all prime numbers up to $n$. The steps of the algorithm are:
1. Write down all integers between $2$ and $n$ (including $2$ and $n$).
2. Find the smallest number that has not been deleted yet and name it $p$; then $p$ is a prime number.
3. Cross out $p$ and all of its multiples that have not been crossed out yet.
4. If there are still numbers not crossed out, go to step $2$.
Write a program that, given $n$ and $k$, finds the $k$-th integer that gets deleted.
Input Format
One line with two integers $n$ and $k$. Their meanings are described in the problem statement.
Output Format
Output one integer on one line, the $k$-th crossed-out integer.
Explanation/Hint
#### Constraints
For $100\%$ of the testdata, $2 \leq k < n \leq 1000$.
#### Notes
#### Source
This problem is translated from [COCI2008-2009](https://hsin.hr/coci/archive/2008_2009/) [CONTEST #2](https://hsin.hr/coci/archive/2008_2009/contest2_tasks.pdf) RESETO. Translator: @[mnesia](https://www.luogu.com.cn/user/115711).
Translated by ChatGPT 5