ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1817. Merry-go-round

I understand test
Posted by Felix_Mate 25 Sep 2016 12:55
Let n=4 and i-1=2. Why ans is 0.687500?
We have 6 variants:
(carousel moves to the "left")

0011
=> Waiting time = 0+0+2+1=3
   Conditional expectation(0011) = 0*(1/4)+0*(1/4)+2*(1/4)+1*(1/4)=3/4
   Probality(0011)=(1/4)*(2/4)+(1/4)*(1/4)=3/16

0101
=> Waiting time = 0+1+0+1=2
   Conditional expectation(0101) = 0*(1/4)+1*(1/4)+0*(1/4)+1*(1/4)=2/4
   Probality(0101)=(1/4)*(1/4)+(1/4)*(1/4)=2/16

0110
=> Waiting time = 0+2+1+0=3
   Conditional expectation(0110) = 0*(1/4)+2*(1/4)+1*(1/4)+0*(1/4)=3/4
   Probality(0110)=(1/4)*(1/4)+(1/4)*(2/4)=3/16

1001
=> Waiting time = 1+0+0+2=3
   Conditional expectation(1001) = 1*(1/4)+0*(1/4)+0*(1/4)+2*(1/4)=3/4
   Probality(1001)=(1/4)*(1/4)+(1/4)*(2/4)=3/16

1010
=> Waiting time = 1+0+1+0=2
   Conditional expectation(1010) = 1*(1/4)+0*(1/4)+1*(1/4)+0*(1/4)=2/4
   Probality(1010)=(1/4)*(1/4)+(1/4)*(1/4)=2/16

1100
=> Waiting time = 2+1+0+0=3
   Conditional expectation(1100) = 2*(1/4)+1*(1/4)+0*(1/4)+0*(1/4)=3/4
   Probality(1100)=(1/4)*(2/4)+(1/4)*(1/4)=3/16

ans = Expected value = Sum(Conditional expectation(mask) * Probality(mask))
ans = (3/4)*(3/16)+(2/4)*(2/16)+(3/4)*(3/16)+(3/4)*(3/16)+(2/4)*(2/16)+(3/4)*(3/16)=(3/4)*(3/16)*4+(2/4)*(2/16)*2=3*(3/16)+2*(2/16)=11/16.


Edited by author 21.06.2017 12:40