CF24D.Broken robot

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of NN rows and MM columns of cells. The robot is initially at some cell on the ii -th row and the jj -th column. Then at every step the robot could go to some another cell. The aim is to go to the bottommost ( NN -th) row. The robot can stay at it's current cell, move to the left, move to the right, or move to the cell below the current. If the robot is in the leftmost column it cannot move to the left, and if it is in the rightmost column it cannot move to the right. At every step all possible moves are equally probable. Return the expected number of step to reach the bottommost row.

输入格式

On the first line you will be given two space separated integers NN and MM ( 1<=N,M<=10001<=N,M<=1000 ). On the second line you will be given another two space separated integers ii and jj ( 1<=i<=N,1<=j<=M1<=i<=N,1<=j<=M ) — the number of the initial row and the number of the initial column. Note that, (1,1)(1,1) is the upper left corner of the board and (N,M)(N,M) is the bottom right corner.

输出格式

Output the expected number of steps on a line of itself with at least 44 digits after the decimal point.

输入输出样例

  • 输入#1

    10 10
    10 4
    

    输出#1

    0.0000000000
    
  • 输入#2

    10 14
    5 14
    

    输出#2

    18.0038068653
    
首页