RESETO
시간 제한: 1000ms메모리 제한: 128MB출처: COCI 2008-2009BOJ 2960
문제
The sieve of Eratosthenes is a famous algorithm to find all prime numbers up to N. The algorithm is:
- Write down all integers between 2 and N, inclusive.
- Find the smallest number not already crossed out and call it P; P is prime.
- Cross out P and all its multiples that aren't already crossed out.
- If not all numbers have been crossed out, go to step 2.
Write a program that, given N and K, find the K-th integer to be crossed out.
입력
The integers N and K (1 ≤ K < N, max(1, K) < N ≤ 1000).
출력
Output the K-th number to be crossed out.
힌트
In the third example, we cross out, in order, the numbers 2, 4, 6, 8, 10, 3, 9, 5 and 7. The seventh number is 9.
예제
예제 1
입력
7 3
출력
6
예제 2
입력
15 12
출력
7
예제 3
입력
10 7
출력
9
코드를 제출하려면 로그인하세요.