Official

A - Chinchirorin Editorial by en_translator


The dice show \(a\), \(b\) and \(c\), so basically, if \(a=b\) then output \(c\), if \(b=c\) then \(a\), if \(c=a\) then \(b\), or otherwise \(0\).
Note that, in order to avoid outputting three times mistakenly when \(a=b=c\), we need to use “else” (or “elif”) statement.
Overall, it can be written using a conditional branch as follows.

Sample code in C++:

#include<bits/stdc++.h>

using namespace std;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) cout << c << endl;
	else if (b == c) cout << a << endl;
	else if (c == a) cout << b << endl;
	else cout << 0 << endl;
	return 0;
}

Sample code in Python:

a, b, c = map(int, input().split())

if a==b: print(c)
elif b==c: print(a)
elif c==a: print(b)
else: print(0)

posted:
last update: