EQLZING - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: S. Manuj Nanthan
Tester: Harris Leung
Editorialist: Nishank Suresh

DIFFICULTY:

823

PREREQUISITES:

None

PROBLEM:

Given two numbers A and B, in one move you can choose an integer d and add d to A while subtracting d from B, or vice versa. Can A and B be made equal?

EXPLANATION:

A and B can be made equal if and only if they have the same parity, i.e, either they are both even or they are both odd.

Proof
  • Suppose they have the same parity. Let A \leq B. Then, choose d = \frac{B-A}{2} and they become equal.
  • Suppose they have different parities. Then, after choosing any d and performing an operation, they will still have different parities. In particular, they can never be made equal, since it will always be the case the one of A and B is even while the other is odd.

TIME COMPLEXITY

\mathcal{O}(1) per test case.

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    a, b = map(int, input().split())
    print('yes' if a%2 == b%2 else 'no')