# CHEFSCORE - Editorial

Author: Tejas Pandey
Testers: Nishank Suresh, Takuki Kurokawa
Editorialist: Nishank Suresh

610

None

# PROBLEM:

On a test with N problems, each giving Chef either 0 or X marks, can Chef obtain a score of exactly Y?

# EXPLANATION:

Since Chef scores either 0 or X on each problem, his final score is going to be kX for some 0 \leq k \leq N.

All that needs to be done is to check whether Y is of this form or not, either by looping across all possible K or by checking a couple of conditions:

• Y should be a multiple of X, i.e, Y%X == 0
• If the first condition holds, 0 \leq \frac{Y}{X} \leq N. Note that the input guarantees that 0 \leq Y \leq N\cdot X so this condition is automatically true and doesn’t need to be checked.

# TIME COMPLEXITY

\mathcal{O}(1) per test case.

# CODE:

Editorialist's code (Python)
for _ in range(int(input())):
n, x, y = map(int, input().split())
print('Yes' if y%x == 0 else 'No')