I understand that the title is a bit unclear, but here is my problem.
'Bob, a Random-Walker, is standing at position X. When he reaches position 0, he would be so happy that he would live there forever. (i.e. stop walking).
But if he reaches position N, he would have a curse which makes him stay there forever.
Every second, Bob has a chance, T, to walk left one unit. He also has a chance (1 - T) to walk right one unit.
Determine the probability that he would find position 0 before he went into the curse (position N).'
Also, X, N are given as integers and T is given as p/q. I shall output the probability as a reduced fraction A/B with B>0.
Here is my question, but I have no clue how to tackle it. There are 3 subtasks:
- N = 2
- N <= 3
- No additional constraints Default constraints: 0 < X < N ≤ 10 (so N ≥ 2 ), 0 ≤ p ≤ q ≤ 50 , q > 0 .
N = 2 is pretty trivial, just output the given p/q.
~~~~~~
N = 3 is already hard for me to get the logic.
Test Case 1: X = 2, N = 3, p = 1, q = 2
The answer should be 1/3 .
~~~~~~ .
General case... No idea.
Any idea or help would be great!
Aucun commentaire:
Enregistrer un commentaire