Equalizing Numbers solution codechef-


Equalizing Numbers solution codechef

Solution – CLICK HERE

Equalizing Numbers solution codechef- Chef has two integers A and B. In one operation he can choose any integer d, and make one of the following two moves :

  • Add d to A and subtract d from B.
  • Add d to B and subtract d from A.

Chef is allowed to make as many operations as he wants. Can he make A and B equal?

Equalizing Numbers solution codechef

  • First line will contain T, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, two integers A, B.

Output Format

For each test case, if Chef can make the two numbers equal print YES else print NO.

You may print each character of the string in uppercase or lowercase (for example, the strings yEsYesYeS, and YES will all be treated as identical).


  • 1 \leq T \leq 1000
  • 1 \leq A,B \leq 1000

Equalizing Numbers solution codechef

Sample 1:



3 3
1 2

Equalizing Numbers solution codechef

Test case 1: Since A and B are already equal, Chef does not need any operations.

Test case 2: It can be shown that A and B can never be made equal using any number of given operations.


Solution – CLICK HERE

Leave a Comment