Number Game

5

1 votes
Problem

We have mugs of two capacity but they don’t have any markings on them neither we can estimate anything(The marked values can only be taken as full, no fractions can be taken of them). Moreover, we have an infinite supply of water. But the problem is there is demand for a fixed amount of water no less, no more. Is it possible to measure the exact amount of water needed using the available mugs?

Input :

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains three integers a, b and m denoting the size of both mugs and the amount of water needed respectively.

Output :

For each test case, print “YES” (Without Quotes) if the measurement is possible and “NO” (Without Quotes) if measurement is not possible.

Constraints :

  • 1 <= T <= 105
  • 1 <= a, b, m <= 105
Sample Input
2
3 5 11
4 6 3
Sample Output
YES
NO
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For the first case, fill out a 5-litre jug once and fill 3-litre jug two times hence, yes we can measure the required amount. 
For the second case, it is not possible to measure 3 litres by any combination.

Contributers:
Editor Image

?