#K92817. Determine a Two-Hour Session
Determine a Two-Hour Session
Determine a Two-Hour Session
You are given the starting time S and ending time E of a session in a 24-hour format. A session is considered exactly two hours long if and only if the difference between E and S, taken modulo 24, is exactly 2. This means that the session can also cross midnight. For example, a session starting at 23 and ending at 1 is exactly 2 hours long.
Your task is to determine for each provided test case whether the session is exactly 2 hours long. Print YES
if the session lasts exactly 2 hours, otherwise print NO
.
Note: All times are in hours on a 24-hour clock (0 to 23). The difference should be computed using modular arithmetic modulo 24.
inputFormat
The first line contains an integer T
denoting the number of test cases. Each of the following T
lines contains two space-separated integers S
and E
representing the start and end times of the session respectively.
outputFormat
For each test case, output a single line containing YES
if the session's duration is exactly 2 hours; otherwise, output NO
.
5
10 12
18 20
9 11
10 11
23 1
YES
YES
YES
NO
YES
</p>