New Start day 3 :2/10/2020 codechef october long CVDRUN
question (source:https://www.codechef.com/OCT20B/problems/CVDRUN)
Covid Run
Covid- is spreading fast! There are cities, numbered from to , arranged in a circular manner. City is connected to city , to , , city to city , and city to city .
The virus is currently at city . Each day, it jumps from its current city, to the city to its right, i.e., from city to the city . As the virus jumps, the cities in between don't get infected. Cities once infected stay infected. You live in city . Find if it will reach your city eventually. If it will, print YES, else print NO.
Input:
- The first line of the input consists of an integer , the number of test cases.
- The first and only line of each test case contains four space-separated integers - , , and , denoting the number of cities, the size of jumps, Covid's current city, and the city that you live in, respectively.
Output:
For each test case, in a new line, print YES if Covid shall reach your city after a finite number of days, else print NO.
Constraints
Subtasks
- Subtask 1 - 100% - Original constraints
Sample Input:
2
6 2 5 3
12 3 4 2
Sample Output:
YES
NO
Explanation:
In the first sample, Covid starts at city , then goes to city , and then from city to city . Thus, it reaches the city that you live in.
In the second sample, Covid starts at city , goes to city , then , then , , , and so on. It never reaches city .

Comments
Post a Comment