Linear Diophantine Equations
Submissions: 415   Accuracy:


  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.

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.

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

1<= T <=100
1<= a, b, c <=105

3 6 9


** 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, generate link and share the link here.

to report an issue on this page.