A - Chinchirorin Editorial by danthespaceman

The key to the problem is to systematically break down the steps of computation. Given three numbers \(a, b, c\), there are three ways two numbers can be equal:

  • \(a = b\): In this case, the answer is \(c\).
  • \(b = c\): In this case, the answer is \(a\).
  • \(c = a\): In this case, the answer is \(b\).

These three cases can overlap, such as when \(a = b = c\). But as shown in Sample Input 3, all 3 cases give the same answer, so there is no need to handle \(a = b = c\) specially.

Now, there is a fourth case to handle: when none of these three cases apply. But in that case, the answer is just 0.

Checking which of these four cases hold can be done using if-else statements in Python, C++, Java, etc., or the equivalent feature in other languages.

Here is an AC Python submission. It uses being able to return early from functions to make sure at most one case gives an answer, but this can be done in other ways.

last update: