A person starts walking from position X = 0, find the probability to reach exactly on X = N if she can only take either 2 steps or 3 steps. Probability for step length 2 is given i.e. P, probability for step length 3 is 1 – P.
Input : N = 5, P = 0.20 Output : 0.32 Explanation :- There are two ways to reach 5. 2+3 with probability = 0.2 * 0.8 = 0.16 3+2 with probability = 0.8 * 0.2 = 0.16 So, total probability = 0.32.
Below is the implementation of the above approach.
- Longest subarray having maximum sum
- Count of different ways to express N as the sum of 1, 3 and 4
- Number of decimal numbers of length k, that are strict monotone
- Number of ways to arrange N items under given constraints
- Value of continuous floor function : F(x) = F(floor(x/2)) + x
- Unique paths in a Grid with Obstacles
- Number of n-digits non-decreasing integers
- Probability of getting at least K heads in N tosses of Coins
- Program to find GCD or HCF of two numbers
- How to check if two given line segments intersect?
- Longest Common Substring | DP-29
- Floyd Warshall Algorithm | DP-16
- Minimum number of jumps to reach end
- Min Cost Path | DP-6
- Longest Increasing Subsequence | DP-3
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mithun Kumar