GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 1 June 2022

[Solution] Is this priority or parity!  CodeChef Solution | CodeChef Problem Solution 2022

N integers 1,2,3,N are placed on a circle in clockwise order such that i and (i+1) are adjacent for all 1iN1, and 1 and N are also adjacent.

Given an integer K, Ashish repeatedly removes integers from the circle until only one integer remains. He does so in the following manner. In each move, Ashish finds the integer which is on the K-th place from the smallest one in clockwise order and removes it from the circle, i.e. its neighbours now become adjacent.

Solution Click Below:-  CLICK HERE

For example, consider the case when N=3 and K=3. Let the circular array [1,2,3] denote the integers on the circle. In the first move, 3 is removed since it is the K-th integer starting from 1, which is the smallest integer currently on the circle. Likewise, in the next move 1 is removed and finally only 2 remains. [1,2,3_][1_,2][2].

Since N and K may be very large, Ashish cannot simulate the process himself. Help him find the parity of the last integer that remains after the repeated removals. In other words, report if this integer is odd or even.

Input Format

  • The first line contains a single integer T — the number of test cases. 
  • Then the test cases follow.
  • The first and only line of each test case contains two integers N and K.

Output Format

For each test case, output ODD if the last integer that remains after the repeated removals is odd, and EVEN otherwise.

Each letter of the output may be printed in either lowercase or uppercase. For example, the strings oddOdd, and ODD will all be treated as equivalent.

Constraints

No comments:

Post a Comment