There is a strange counter. At the first second, it displays the number 3. Each second, the number displayed by decrements by 1 until it reaches 1. In next second, the timer resets to 2 X the initial number for the prior cycle and continues counting down. The diagram below shows the counter values for each time t in the first three cycles:
Find and print the value displayed by the counter at time t.
Function Description
Complete the strangeCounter function in the editor below.
strangeCounter has the following parameter(s):
- int t: an integer
Returns
- int: the value displayed at time t
Input Format
A single integer, the value of t.
Constraints
- 1 <= t <= 1012
Subtask
- 1 <= t <= 105 for 60% of the maximum score.
Sample Input
1 | 4 |
Sample Output
1 | 6 |
Explanation
Time t = 4 marks the beginning of the second cycle. It is double the number displayed at the beginning of the first cycle: . This is shown in the diagram in the problem statement.
Solution
1 | /* |