Official algorithmic problem description and constraints.
Yousef is at the coordinates (0,0)
and wants to reach a plate of Koshary at (π₯,π¦)
.
To get there, Yousef takes long steps. From any point (π,π)
, a long step moves him to:
However, Yousef is allowed to take at most one short step during his entire journey. A short step moves him to:
Can Yousef reach the exact coordinates (π₯,π¦)
of the Koshary plate?
Input
The first line contains an integer π‘
(1β€π‘β€100
) β the number of test cases.
Each test case contains two integers π₯
and π¦
(1β€π₯,π¦β€10
) β the coordinates of the Koshary plate.
Output
For each test case, output "YES" if Yousef can reach the Koshary plate and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Example
Input
Copy
6 1 1 1 2 4 6 5 9 7 2 10 10
Output
Copy
NO YES YES NO YES YES
Note
In the first test case, it is impossible to reach (1,1)
using the mentioned steps.
In the second test case, an optimal sequence of steps would be:
(0,0)β
β
β
β
ππππ
(0,2)β
β
β
β
β
πππππ
(1,2)
In the third test case, an optimal sequence of steps would be:
(0,0)β
β
β
β
ππππ
(0,2)β
β
β
β
ππππ
(2,2)β
β
β
β
ππππ
(2,4)β
β
β
β
ππππ
(4,4)β
β
β
β
ππππ
(4,6)
Detailed video explanations, mathematical intuition, and clean C++ implementation code.