Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link

The Wooden Plates : WODPLT043 | CodeChef Solution

1 min read


Problem

You and your friend are playing a game with hoops. There are NN hoops (where NN is odd) in a row. You jump into hoop 11, and your friend jumps into hoop NN. Then you jump into hoop 22, and after that, your friend jumps into hoop N-1N−1, and so on.

The process ends when someone cannot make the next jump because the hoop is occupied by the other person. Find the last hoop that will be jumped into.

Input Format

  • The first line contains an integer TT, the number of test cases. Then the test cases follow.

  • Each test case contains a single line of input, a single integer N.

Output Format

For each testcase, output in a single line the answer to the problem.

Constraints

  • 1 \leq N \lt 2\cdot 10^5
  • N is odd

Example / Sample:

Input:
2
1
3

Output:

yes
yes
no
no
yes

Solution

#include <iostream>
using namespace std;

// Solution from : Code Radius [ https://radiuscode.blogspot.com/ ]

int main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
cout<<n/2+1<<endl;
}
}

Please First Try to Solve Problem by Yourself.

You may like these posts

Post a Comment