The Wooden Plates: WODPLT043

The Wooden Plates Codechef Solution

Codechef Problem Link (CU Access only) :-https://www.codechef.com/CUCSE2AP0001/problems/WODPLT043

You and your pal are playing a jumping game. There are NN wooden plates in a row (where NN is an odd number). You jump into plate 11, and your friend jumps into plate NN. Then you jump into plate 22, and your friend follows you into plate N−1N−1, and so on.

The procedure comes to an end when someone is unable to make the following jump because the plate is occupied by someone else. Locate the last plate to be jumped into.

Input Format

  • The first line comprises an integer TT, which represents the number of test cases. Then come the test cases.
  • Each test case has a single line of input, containing a single number NN.

Output Format

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

Constraints

  • 1≤T≤1051≤T≤105
  • 1≤N<2⋅1051≤N<2⋅105
  • NN is odd

Subtasks

Subtask #1 (100 points): original constraints

Sample Input 1

2
1
3

Sample Output 1

1
2

Explanation

Test Case 11: Since there is only 11 plate, that’s the only one to be jumped into.

Test Case 22: The first player jumps into plate 11. The second player jumps into plate 33 and finally, the first player jumps into plate 22. Then the second player cannot make another jump, so the process stops

The Wooden Plates Codechef Solution in C++ 17

int main() {
	// your code goes here
	int t; cin>>t;
	int n;
	while(t--){
	    cin>>n;
	    cout<< (n/2+1)<< endl;
	}
	return 0;
}

The Wooden Plates Codechef Solution in Python

# cook your dish here
n=int(input())
for i in range(n):
    t=int(input())
    if(t==1):
        print(t)
    elif(t%2!=0):
        a=t/2
        print(int(a)+1)
    else:
        v=t/2
        print(v)
    

The Wooden Plates Codechef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int i=0;i< t;i++)
		{
		    int n = sc.nextInt();
		    System.out.println((n+1)/2);
		}
	}
}

The Wooden Plates Codechef Solution by

The Wooden Plates Codechef Solution
The Wooden Plates Codechef Solution

The content uploaded on this website is for reference purposes only. Please do it yourself first.