PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
You have a pair of standard dice.
You rolled one of them and received X.
Is it possible to roll the other one and get a sum of 9?
EXPLANATION:
The second die can give a value in [1, 6].
If the value given by the second die is Y, then we want X+Y = 9 to hold.
This means Y = 9-X is the fixed value to roll, and this should be in [1, 6].
So,
- If X = 1 or X = 2, Y = 9-X will be 8 or 7 respectively, and not inside the [1, 6] range.
For these two values, the answer isNo. - If 3 \le X \le 6 then Y = 9-X will be between 3 and 6, which is in the [1, 6] range.
For all these values, the answer isYes.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
x = int(input())
if x <= 2: print('No')
else: print('Yes')