WC '16 Contest 1 S4 - TP

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Woburn Challenge 2016-17 Round 1 - Senior Division

You and your friends have had enough of this Halloween nonsense. You nabbed your fair share of candy in the past, sure, but you wouldn't be caught dead parading around in a costume now that you're in high school. That doesn't mean this dumb excuse for a holiday has to go to waste, though… No way. It's time to have some real fun.

There are N (2 \le N \le 10^7) nice-looking houses on your street, but they won't be looking nice for long. Having borrowed your family car for the night, you'll be taking a joy ride down the street with your friends and some bathroom supplies in tow. Your plan is to take M (1 \le M \le 2\,000) passes along the street, and on each pass, you'll choose a random pair of distinct houses (chosen uniformly at random from all possible pairs) to be your targets. Then, those two houses will each receive a little punishment… Bam! Toilet paper to the face!

Once you've TP-ed a house in this fashion, it will be thoroughly covered in the stuff. It may get chosen as a target again on future passes, but applying toilet paper multiple times will have no additional effect on it.

This is sure to be a sweet night, but now you're wondering just how much carnage you and your friends will inflict on your lame neighbourhood. What's the expected number of different houses which will have been TP-ed at least once by the end of Halloween?

In test cases worth 4/35 of the points, N \le 5 and M \le 5.
In test cases worth another 5/35 of the points, N \le 10 and M \le 10.
In test cases worth another 18/35 of the points, N \le 1\,000 and M \le 1\,000.

Input Specification

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

Output Specification

Output one line consisting of a single real number - the expected number of houses which will be covered in toilet paper after all M passes, with at most 10^{-5} absolute or relative error.

Sample Input

3 2

Sample Output

2.666667

Sample Explanation

There are 3 possible pairs of distinct houses - (1, 2), (1, 3), and (2, 3). Therefore, there are 9 equally-likely pairs of houses which will be TP-ed on the two passes. 3 of these result in only 2 distinct houses being covered in toilet paper (for example, (1, 2) being targeted on both passes). The other 6 of them result in all 3 houses being covered. Therefore, the expected number of houses which will be covered in toilet paper is (3 \times 2 + 6 \times 3) / 9 = 8 / 3.


Comments

There are no comments at the moment.