PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: nikhil_010309
Tester: raysh07
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
You have an X-sided die that has the first X multiples of K written on it.
Given Y, decide if it’s possible for the die to show it when rolled.
EXPLANATION:
Y can be shown only if it’s among the first X multiples of K.
This means:
- Y should be a multiple of K, and
- \frac{Y}{K} should not exceed X.
In most languages, the first condition can be checked as y % k == 0 and the second condition as y/k <= x.
If both conditions are true, the answer is Yes, otherwise the answer is No.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
x, k, y = map(int, input().split())
print('Yes' if y%k == 0 and y//k <= x else 'No')