### COCI 2008/2009, Contest #2

## Task RESETO

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.

### Input

The integers N and K (2 ≤ K < N ≤ 1000).### Output

Output the K-th number to be crossed out.### Examples

## Input7 3 ## Output6 |
## Input15 12 ## Output7 |
## Input10 7 ## Output9 |

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.

All Submissions

Best Solutions

**Point Value:** 5

**Time Limit:** 2.00s

**Memory Limit:** 16M

**Added:** Nov 21, 2008

**Languages Allowed:**

C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

ilovepion Jan 07, 2011 - 10:59:22 pm UTC i dont get itbbi5291on Jan 07, 2011 - 11:01:41 pm UTC Re: i dont get it3. Cross out P and all its multiples that aren't already crossed out.

tip: ppl get annoyed if u type liek this.

ilovepion Jan 26, 2011 - 2:00:18 pm UTC Re: Re: i dont get itlate reply

LOLZ

GeerthanSrikantharajahon Jan 22, 2011 - 4:09:33 pm UTC ????bbi5291on Jan 22, 2011 - 4:52:14 pm UTC Re: ????It helps us debug if you indent your code.

ilovepion Jan 22, 2011 - 11:34:37 pm UTC Re: Re: ????BTW, you don't always have to copy codes from PEG. Try making codes of your own, following what they taught you with the original code.

helios26on Jan 12, 2011 - 2:57:26 am UTC Confused XD~helios

bbi5291on Jan 12, 2011 - 6:14:35 am UTC Re: Confused XDNiemaon Jan 08, 2011 - 4:09:51 pm UTC help plsssbbi5291on Jan 09, 2011 - 12:37:24 am UTC Re: help plsss