[Solution] Infinity Staircase CodeChef Solution | CodeChef Problem Solution 2022
You are climbing an infinity staircase, which (as its name suggests) has an infinite number of steps. You are currently standing at the st step, and you would like to reach the -th step. When standing at the -th step, you can make one of the following three moves:
- Move to step
- Move to step
- Move to step
However, you can't make the same move twice in a row.
For example, suppose you reach the th step from the th step using the third move. Then, from the th step, you can move to either the th or the th step (using the st or nd move) — but you can't move to the th step (because you would use the third move twice in a row).
Now suppose you choose the st move and move to the th step. On your next move, you cannot move to the th step, but you can move to either the th or the th step.
Under these conditions, find the minimum number of moves you need to reach the -th step.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of a single line containing one integer, .
Output Format
- For each test case, print on a new line the minimum number of moves required to reach the -th step.
No comments:
Post a Comment