Sticker Album
Time limit2sMemory limit512 MB
Each pack holds a uniformly random integer count of stickers from A to B; find the expected number of packs needed to collect at least N stickers.
- Level
Medium6 of 10
- Topics
- Probability, Dynamic programming, Math, Prefix sum
- Solved
- No attempts yet
Problem
The sticker album for the ICPC 2020 Nlogonian Subregional is now available in Nlogonia! Competitive programmers from all over the country are buying albums and collecting stickers to celebrate the contest.
This album is special because all stickers are identical: each contains a photo of this year's trophy. To complete the album, you just have to collect enough stickers to fill all the spaces in it.
You might wonder: what is the fun of collecting these stickers? To make things interesting, the stickers are sold in packs, each with a random number of stickers. Fans celebrate when they find many stickers in a pack, tease the unlucky ones who find few stickers, and boast about filling their albums with few packs.
You have just acquired your album and are ready to start filling it! But before buying sticker packs, you wondered: on average, how many packs are needed to complete one album?
Input
There is a single line of input containing three integers, N, A and B, separated by a space, satisfying 1 ≤ N ≤ 10^6, 0 ≤ A ≤ B ≤ 10^6 and B > 0, where:
- N is the number of stickers needed to fill the album;
- A is the minimum number of stickers in a pack;
- B is the maximum number of stickers in a pack.
The number of stickers in each pack is an integer uniformly distributed in the closed interval [A, B].
Output
The output consists of a single line, which must contain the expected number of packs needed to complete an album. The number will be considered correct if it is within an absolute or relative error of 10^-5 of the correct answer.