ODDSUMPAIR - Editorial

PROBLEM LINK:

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

Author: Jeevan Jyot Singh
Testers: Tejas Pandey, Hriday
Editorialist: Nishank Suresh

DIFFICULTY:

TBD

PREREQUISITES:

None

PROBLEM:

You have three numbers A, B, and C. Does there exist a pair of them that sums to an odd integer?

EXPLANATION:

The only way for two integers to sum to an odd one is if one of them is even and the other is odd.

So, the answer is “No” if either all of A, B, C are even or all three are odd, and “Yes” in every other case.

Alternately, you can just compute all three sums and check whether any of them is odd.

TIME COMPLEXITY

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

CODE:

Editorialist's code (Python)
for _ in range(int(input())):
    a, b, c = map(int, input().split())
    s = {a%2, b%2, c%2}
    print('Yes' if len(s) == 2 else 'No')