Official

A - 1-2-4 Test Editorial by en_translator


The score of the test and the results for the individual problems correspond as follows:

 Score   Problem \(1\) (\(1\) points)   Problem \(2\) (\(2\) points)   Problem \(3\) (\(4\) points)    Score written in base \(2\) 
0 × × × \(000\)
1 × × \(001\)
2 × × \(010\)
3 × \(011\)
4 × × \(100\)
5 × \(101\)
6 × \(110\)
7 \(111\)

(Here, ✔ means correct and × means wrong.) Therefore, in the binary notation of the score, problem \(i\) is correctly answered if the \(i\)-th (\(1\leq i\leq 3\)) least significant digit is \(1\), and wrong otherwise.

Next, for each problem, let us correspond “correct” with \(1\) and “wrong” with \(0\), then Snuke’s result is dependent on Takahashi’s and Aoki’s result as follows:

Takahashi  Aoki  Snuke
\(0\) \(0\) \(0\)
\(0\) \(1\) \(1\)
\(1\) \(0\) \(1\)
\(1\) \(1\) \(1\)

This is nothing but OR operation. Since we need to compute bitwise (problem-wise) and sum them up, we can just take the OR as an entire integer; when Takahashi and Aoki scored \(A\) and \(B\) points, Snuke’s score is expressed as \((A|B)\) points (where \(x|y\) denotes the OR operation of \(x\) and \(y\)).

Therefore, it is sufficient to print this value.
Bitwise operations are fundamental elements of computation, so if you are not quite sure, we recommend you check again, as well as the AND and XOR operations.

Sample code in C++:

#include <bits/stdc++.h>
using namespace std;

int main() {
	int a, b;
	cin>>a>>b;
	cout<<(a|b)<<endl;
	return 0;
}

Sample code in Python:

a,b = map(int, input().split())
print(a|b) 

posted:
last update: