atcoder#AGC007C. [AGC007C] Pushing Balls
[AGC007C] Pushing Balls
Score : points
Problem Statement
There are balls and holes in a line. Balls are numbered through from left to right. Holes are numbered through from left to right. The -th ball is located between the -th hole and -th hole. We denote the distance between neighboring items (one ball and one hole) from left to right as (). You are given two parameters and . is equal to for all ().
We want to push all balls into holes one by one. When a ball rolls over a hole, the ball will drop into the hole if there is no ball in the hole yet. Otherwise, the ball will pass this hole and continue to roll. (In any scenario considered in this problem, balls will never collide.)
In each step, we will choose one of the remaining balls uniformly at random and then choose a direction (either left or right) uniformly at random and push the ball in this direction. Please calculate the expected total distance rolled by all balls during this process.
For example, when , , and , the following is one possible scenario:
- first step: push the ball numbered to its left, it will drop into the hole numbered . The distance rolled is .
- second step: push the ball numbered to its right, it will pass the hole numbered and drop into the hole numbered . The distance rolled is .
- third step: push the ball numbered to its right, it will drop into the hole numbered . The distance rolled is .
So the total distance in this scenario is .
Note that in all scenarios every ball will drop into some hole and there will be a hole containing no ball in the end.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print a floating number denoting the answer. The relative or absolute error of your answer should not be higher than .
1 3 3
4.500000000000000
The distance between the only ball and the left hole is and distance between the only ball and the right hole is . There are only two scenarios (i.e. push left and push right). The only ball will roll and unit distance, respectively. So the answer for this example is .
2 1 0
2.500000000000000
1000 100 100
649620280.957660079002380