[Solution] Is this priority or parity! CodeChef Solution | CodeChef Problem Solution 2022
integers are placed on a circle in clockwise order such that and are adjacent for all , and and are also adjacent.
Given an integer , 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 -th place from the smallest one in clockwise order and removes it from the circle, i.e. its neighbours now become adjacent.
For example, consider the case when and . Let the circular array denote the integers on the circle. In the first move, is removed since it is the -th integer starting from , which is the smallest integer currently on the circle. Likewise, in the next move is removed and finally only remains. .
Since and 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 — the number of test cases.
- Then the test cases follow.
- The first and only line of each test case contains two integers and .
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 odd
, Odd
, and ODD
will all be treated as equivalent.
No comments:
Post a Comment