#P6421. [COCI 2008/2009 #2] RESETO
[COCI 2008/2009 #2] RESETO
Description
The Sieve of Eratosthenes is a well-known method for finding all prime numbers up to . The steps of the algorithm are:
- Write down all integers between and (including and ).
- Find the smallest number that has not been deleted yet and name it ; then is a prime number.
- Cross out and all of its multiples that have not been crossed out yet.
- If there are still numbers not crossed out, go to step .
Write a program that, given and , finds the -th integer that gets deleted.
Input Format
One line with two integers and . Their meanings are described in the problem statement.
Output Format
Output one integer on one line, the -th crossed-out integer.
7 3
6
15 12
7
10 7
9
Hint
Constraints
For of the testdata, .
Notes
Source
This problem is translated from COCI2008-2009 CONTEST #2 RESETO. Translator:
https://www.luogu.com.cn/user/115711
Translated by ChatGPT 5
京公网安备 11011102002149号