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 points obtained 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
- 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.
Output Format
For each test case, output in a single line the number of times Chef served from the right side of the court.
Constraints
Sample Input 1
4
2
9
53
746
Sample Output 1
2
5
27
374
Explanation
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: .
Solution:
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
cout<<(n/2)+1<<endl;
}
return 0;
}
No comments:
Post a Comment