Please Fill out the Feedback Form for Code Radius

The Wooden Plates : WODPLT043 | CodeChef Solution

1 min read


Problem

You and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into hoop 2 and after that, your friend jumps into hoop N-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 T, 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

Sample

Input
2
1
3
Output
1
2

Explanation

Test Case 1: Since there is only 1 hoop, that's the only one to be jumped into.
Test Case 2: The first player jumps into hoop 1. The second player jumps into hoop 3 and finally the first player jumps into hoop 2. Then the second player cannot make another jump, so the process stops.

Solution

cpp
#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

  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  •  ProblemYou're given an integer N. Write a program to calculate the sum of all the digits of N. Please Share this article... Input Format The first line contains an intege…
  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…
  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…

Post a Comment