Linear Diophantine Equations
Submissions: 412   Accuracy:

34.69%

  Difficulty: Basic   Marks: 1

A Diophantine equation is a polynomial equation, usually in two or more unknowns, such that only the integral solutions are required. An Integral solution is a solution such that all the unknown variables take only integer values.

Given three integers a, b, c representing a linear equation of the form : ax + by = c. Determine if the equation has a solution such that x and y are both integral values.

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integers a, b and c.

Output:

If the equation has possible integral solutions print 1 else print 0. Print the answer for each test case in a new line.


Constraints:

1<= T <=100

1<= a, b, c <=100000


Example:

Input:

1

3 6 9

Output:

1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.