Map Generator
Time limit1sMemory limit128 MB
Given N planets each edge appears independently with probability P, find the probability that the resulting random graph is connected.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Probability
- Solved
- No attempts yet
Problem
In a space-themed game, mankind is scattered across mutually hostile planets. Travel between planets uses special hyperspace tunnels. Each tunnel connects two planets and works for two-way communication. At most one tunnel may connect any pair of planets. The set of all tunnels is called the map of the game.
The map is generated at random by the following procedure. For each pair of distinct planets and (), a real number () is generated independently from the uniform distribution. If , where is a given real parameter, the tunnel connecting planets and is added to the map. (Consequently each pair is connected independently with probability .)
A map is connected if, between every pair of planets, there is a path made of one or more tunnels. Given and , compute the probability that this procedure generates a connected map.
Input
The first line contains an integer ().
The second line contains a real number ().
Output
Print, on a single line, the probability that the generated map is connected, rounded to exactly 6 digits after the decimal point (for example, 0.500000).