409573: GYM103637 A Agile permutation

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Agile permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given an integer $$$n$$$ and a permutation of numbers $$$p_1, p_2, ... , p_n$$$. You are also given two integers $$$a, b$$$. There are 2 types of operations. The first type: swap any two elements of the permutation for the price of $$$a$$$ coins. The second type: shuffle the permutation randomly for the price of $$$b$$$ coins. You are allowed to make any number of operations of each type in any order. Your goal is to get identity permutation($$$1, 2, ... , n$$$) from the given one. You need to find the mathematical expectation of the number of spent coins on achieving the goal with the optimal strategy.

Input

The first line of the input file consists of numbers $$$n, a, b$$$, separated by spaces.

The second line contains the permutation $$$p$$$ of length $$$n$$$, elements are separated by spaces.

$$$$$$1 \le n \le 20$$$$$$ $$$$$$1 \le a, b \le 1000$$$$$$ $$$$$$1 \le p_i \le n$$$$$$

Output

Output single number: the mathematical expectation of the number of spent coins. Your answer will be considered correct, if it's absolute or relative error don't exceed $$$10^{-9}$$$.

ExamplesInput
2 5 5
1 2
Output
0.00000000000000000000
Input
2 5 1
2 1
Output
2.00000000000000000000

加入题单

上一题 下一题 算法标签: