Badminton Serves solution codechef
Chef is playing badminton today. The service rules of this singles game of badminton are as follows:
- The player who starts the game serves from the right side of their court.
- Whenever a player wins a point, they serve next.
- If the server has won an even number of points during a game, then they will serve from the right side of the service court for the subsequent point.
Chef will be the player who begins the game.
Given the number of pointsobtained by Chef at the end of the game, please determine how many times Chef served from the right side of the court.
Please see the sample cases below for explained examples.
Input Format Badminton Serves solution codechef
- The first line of input contains a single integer , denoting the number of test cases. The description of test cases follows.
- Each test case consists of a single line containing one integer , the points obtained by Chef.
For each test case, output in a single line the number of times Chef served from the right side of the court.
Badminton Serves solution codechef Sample Input 1
4 2 9 53 746
Sample Output 1
2 5 27 374
Explanation Badminton Serves solution codechef
Test case: Chef obtained points at the end of the game. This means he served two times from the right side of the court, once when his score was and once again when his score was .
Test case: Chef obtained points at the end of the game. This means he served times from the right side of the court. The points when he had to serve from right were: .