WC '18 Contest 2 S3 - Multitasking

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 128M

Problem type
Woburn Challenge 2018-19 Round 2 - Senior Division

Ilsa Faust, an experienced former MI6 agent, has agreed to join the IMF and work alongside Ethan Hunt!

As part of her onboarding process at the secret IMF headquarters in Ottawa, Ilsa is required to complete a training exercise involving defusing a bomb. However, she feels that simply defusing a bomb would be an insultingly easy task for her, so she's going to show off her multitasking skills and defuse N (1 \le N \le 2\,000) bombs all at once!

Each bomb becomes defused as soon as two particular wires are both cut. As such, Ilsa will need to cut 2N wires in total to complete the exercise.

It's understandably rather difficult to keep track of that many wires, so Ilsa is going to cut the 2N wires in a random order. Specifically, until she's all done, she'll repeatedly select one of the remaining uncut wires at uniform random, and cut it.

Ethan was hoping to meet up with Ilsa, but he's walked in while the training session is underway, at a random point in time after she's cut some unknown number of wires x between 0 and 2N - 1, inclusive (and so has defused between 0 and N - 1 bombs, inclusive). Note that all 2N possible values of x are equally likely before Ethan enters the room. Upon entering, he'd like to estimate how much longer Ilsa will be busy. It's too difficult to count exactly how many wires Ilsa has already cut, but Ethan counts that K (0 \le K \le N - 1) bombs have been defused so far. Given that fact, what's the expected number of remaining wires Ilsa has yet to cut?

Subtasks

In test cases worth 9/25 of the points, N \le 5.
In test cases worth another 12/25 of the points, N \le 200.

Input Specification

The first and only line of input consists of two space-separated integers, N and K.

Output Specification

Output a single real number, the expected number of remaining wires Ilsa has yet to cut. Your answer must have at most 10^{-5} absolute or relative error to be judged as correct.

Sample Input 1

1 0

Sample Output 1

1.5

Sample Input 2

2 0

Sample Output 2

3.125

Sample Input 3

2 1

Sample Output 3

1.25

Sample Explanation

In the first case, when the single bomb hasn't yet been defused, it's equally likely that Ilsa has cut either 0 or 1 wires so far (and so has either 2 or 1 wires remaining). Therefore, the expected number of wires she has yet to cut is \frac{2 + 1}{2} = 1.5.


Comments

There are no comments at the moment.