Factory
Time limit2sMemory limit1024 MB
Given room counts a and b, decide whether repeatedly doubling the smaller room with people from the larger one can make both rooms equal.
- Level
Medium5 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Machines use the body heat and electrical activity of people to produce energy. They even have their own factories to produce and process this energy.
In one of these factories, energy is produced as follows. People are placed in two rooms. In the first room, heat is taken from each person, and in the second room, electrical activity is taken. For the most productive energy production, both rooms must hold the same number of people.
An hour ago, a riot broke out. Some people escaped, and the rest got mixed up. Now the first room holds people and the second room holds . The machines want both rooms to hold the same number of people. However, their software only lets them double the number of people in the room with fewer people, using people taken from the other room. For example, if the first room has three people and the second has five, one step can move three people from the second room to the first. Can the machines make the counts equal with these operations?
Input
The first line contains an integer (), the number of test cases. Each of the next lines contains two integers and ().
Output
For each test case, print <<YES>> if the machines can make the number of people in the two rooms equal, and <<NO>> otherwise. Print one answer per line.