This page is still under construction.

Parts of this page are still being built. What you see may change.

Map Generator

Time limit1sMemory limit128 MB

Summary
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 NN 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 ii and jj (1≤i<j≤N1 \le i < j \le N), a real number XijX_{ij} (0≤Xij≤10 \le X_{ij} \le 1) is generated independently from the uniform distribution. If Xij≤PX_{ij} \le P, where PP is a given real parameter, the tunnel connecting planets ii and jj is added to the map. (Consequently each pair is connected independently with probability PP.)

A map is connected if, between every pair of planets, there is a path made of one or more tunnels. Given NN and PP, compute the probability that this procedure generates a connected map.

Input

The first line contains an integer NN (1≤N≤201 \le N \le 20).

The second line contains a real number PP (0≤P≤10 \le P \le 1).

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).

Examples2

  1. Example 1

    Input
    3
    0.5
    
    Expected output
    0.500000
    
  2. Example 2

    Input
    2
    0.25
    
    Expected output
    0.250000