CodechefApr 30, 2025

Test Score

Hazrat Ali

Codechef

In a test, there are NN problems, each carrying XX marks.
In each problem, Chef either received XX marks or 00 marks.

Determine whether is it possible for Chef to achieve exactly YY marks.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • Each test case consists of three integers N,X,N,X, and YY, the number of problems, the maximum score for each problem, and the score Chef wants.

Output Format

For each test case, output YES if Chef can achieve exactly YY marks, NO otherwise.

You can print each character of the string in uppercase or lowercase. For example, the strings YesYESyes, and yEs, are all considered identical.

Constraints

  • 1≤T≤100
  • 1≤N≤10
  • 1≤X≤10
  • 0≤Y≤N⋅X

Sample 1:

Input
 
5
1 8 4
3 6 12
4 5 0
10 10 100
8 5 36

Output
NO
YES
YES
YES
NO

Explanation:

Test case 11: There is no way for Chef to score exactly 44 marks.

Test case 22: Chef can score 1212 marks by receiving 66 marks in 22 problems and 00 marks in 11 problem.

Test case 33: Chef can score 00 marks by receiving 00 marks in each of the 44 problems.

Test case 44: Chef can score 100100 marks by receiving 1010 marks in each of the 1010 problems.

Test case 55: There is no way for Chef to score exactly 3636 marks.

 

Solution 

for _ in range(int(input())):
    m,x,y=map(int, input().split())
   
    a=0
    for i in range(1,m+1):
        if x*i==y:
            a+=1
    if a==1 or y==0:
        print("YES")
    else:
        print("NO")
           

 

Comments