ou are given an array B of n integers. Then the array A is created using array B as following : for each i (1 <= i <= n), we set Ai = Bi + d with the probability Pi, otherwise Ai = Bi. find the expect number of swaps that bubble sorting will make when the array A is sorted .......
for example if input is this n=4 d=7 elements of array B = 5 6 1 7 probability of array of elements B = 25 74 47 99\ answer=1.6049
Admins .. please remove this post .. this's the solution to a problem from july challenge in codechef!!
This is not even his code... He copied it from fushar's blog.