This page is still under construction.

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

Map Generator Returns (MG-II)

Time limit1sMemory limit128 MB

Summary
Given N places and independent edge probability P, find the probability that the random graph on N vertices is connected.
Level

Medium7 of 10

Topics
Probability, Dynamic programming, Combinatorics, Graph
Solved
No attempts yet

Problem

You have just finished your research on the FAMI algorithm (see the earlier task “Map Generator”). You are very proud of yourself and even expect a bonus this month. Your boss, whose nickname is Dean, asks you to come to his office for a moment. You expect thanks and even a promotion. But…

“What is this?” asks Dean, showing you your latest report.

“Well, um, these are the results of my FAMI algorithm research…” you answer. It seems that your dreams of a promotion soon are… just dreams. Yet you still do not understand what is wrong with your report.

“I can read, by the way,” Dean continues. “I am talking about the absolute error. Why is it so big? I require better results!”

When you argue with your boss, the best argument is silence. So now, instead of a bonus and a promotion, you need to rewrite your program.

The FAMI algorithm builds a map as follows. The map has NN places. For each unordered pair of two distinct places (there are (N2)\binom{N}{2} such pairs), FAMI independently, with probability PP, builds a two-way road connecting them. The generated map is connected if you can travel between every pair of places using roads only. Find the probability that FAMI generates a connected map.

Input

The input consists of two lines. 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 FAMI generates a connected map, rounded to exactly 1010 digits after the decimal point.

Examples4

  1. Example 1

    Input
    3
    0.5
    
    Expected output
    0.5000000000
    
  2. Example 2

    Input
    1
    0.5
    
    Expected output
    1.0000000000
    
  3. Example 3

    Input
    2
    0.3
    
    Expected output
    0.3000000000
    
  4. Example 4

    Input
    4
    0.5
    
    Expected output
    0.5937500000