An equation of the form ax + by = c is a Diophantine equation,
where a, b, and c are positive integers.
Such an equation has no integer solution if the greatest common
divisor of a and b does not divide c. If it does divide c, then a
solution exists.
The greatest common divisor (gcd) of two positive integers, is the
largest integer that divides both a and b. For example, the gcd of
2 and 6 is 2. The gcd of 9 and 12 is 3. The gcd of 15 and 7 is
1.
Given a diophantine equation, determine if it has any
solutions.
Input
A positive integer, denoting the number of equations.
A diophantine equation. Each equation will be of the form:
<num>x+<num>y=<num>,
where <num> denotes a positive
integer(<=65536). Each equation will be on a
separate line and will contain no blanks.
Output
The phrase “<equation> has a
solution.” if a solution exists, or the phrase
“<equation> has no solution.” if one
does not exist, where <equation> is
the equation in question.
Sample Input
2 2x+5y=11 60x+18y=97
Sample Output
2x+5y=11 has a solution. 60x+18y=97 has no solution.
代码:
#include<stdio.h>
int gcd(int a,int b);
int main()
{
}
int gcd(int a,int b)
{
}