#P6421. [COCI 2008/2009 #2] RESETO

    ID: 7184 远端评测题 1000ms 32MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>模拟数学2008COCI(克罗地亚)

[COCI 2008/2009 #2] RESETO

Problem Description

The Sieve of Eratosthenes is a well-known method for finding all prime numbers up to nn. The steps of the algorithm are:

  1. Write down all integers between 22 and nn (including 22 and nn).
  2. Find the smallest number that has not been deleted yet and name it pp; then pp is a prime number.
  3. Cross out pp and all of its multiples that have not been crossed out yet.
  4. If there are still numbers not crossed out, go to step 22.

Write a program that, given nn and kk, finds the kk-th integer that gets deleted.

Input Format

One line with two integers nn and kk. Their meanings are described in the problem statement.

Output Format

Output one integer on one line, the kk-th crossed-out integer.

7 3
6
15 12
7
10 7
9

Hint

Constraints

For 100%100\% of the testdata, 2k<n10002 \leq k < n \leq 1000.

Notes

Source

This problem is translated from COCI2008-2009 CONTEST #2 RESETO. Translator:

https://www.luogu.com.cn/user/115711

Translated by ChatGPT 5