How to solve this ques?

I can,t understand the test case how it is calculated

Expected is just probability of each case it can go to multiplied by the expected turns that will take + 1 for that turn itself.

didn’t get that.

This explains it in detail:
https://codeforces.com/blog/entry/64250?#comment-523543

how do we get to know about states required in a dp

Can anyone provide me a link which explains all expectation concepts ?