You are playing a game with \(N\) cards that are marked from \(1\) to \(N\). The rules of the game are as follows:
- In each turn, you remove some cards. The game goes on until only one card is left.
- If the number of cards that are left is odd, then preserve the card with the smallest number and randomly remove half of the remaining available cards.
- If the number of cards that are left is even, then randomly remove half of the available cards.
Write a program to determine the probability that the \(X^{th}\) card is the last one remaining.
Input format
The first and only line contains two space-separated integers \(N\) and \(X\)
Output format
Print the probability of the \( X^{th}\) card being the last-remaining card in the game.
Constraints
\(1 ≤ N ≤ 14\)
\(1 ≤ X ≤ N\)
In this case both cards have equal probability of being present in the end as well equal probability of being destroyed.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor