Survival Probability of a Water Flea
Time limit5sMemory limit512 MB
Count the paths of length n on a line starting at k that never return to 0, so the survivor count is S in S/2^n.
- Level
Medium6 of 10
- Topics
- Combinatorics, Dynamic programming, Math
- Solved
- No attempts yet
Problem
A water flea is centimeters below the water surface. Every second it moves 1 centimeter up or 1 centimeter down, each with probability . The moment the water flea touches the surface, the whirligig beetles waiting there eat it. If , the water flea starts on the surface and is eaten immediately.
For example, a water flea 2 centimeters below the surface can move in 8 ways over 3 seconds: "up up up, up up down, up down up, ..., down down down". Each of these ways has the same probability . In the ways "up up up" and "up up down", the water flea reaches the surface after 2 seconds and is eaten. In the other 6 ways it stays alive below the surface, so its survival probability after 3 seconds is .
The probability that a water flea centimeters below the surface is still alive after seconds is . Compute .
Input
The first line contains and . ()
Output
Print on the first line.