PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: iceknight1093
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
There were four pieces of paper, with the values 1, 2, 3, 4 written on them.
One piece went missing, and the sum of the remaining pieces equals S.
What is the missing piece?
EXPLANATION:
If we had all four pieces, the total sum would equal 1+2+3+4 = 10.
We have three pieces, and their sum is S.
So, if the missing piece has value x, we have the equation
S+x = 10
Thus, we have
x = 10-S
and this is the answer.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
s = int(input())
print(10 - s)