Problem Description
Description
Xiao Ke is a middle school student, and she is very troubled right now because her teacher assigned her a troublesome homework. Can you help her? The problem information is as follows.
Given the linear Diophantine equation ax+by=n, determine whether this equation has integer solutions, where x and y are unknowns, a, b, and n are all integers and none of them is zero, and 0<a,b,n<2^16-1.
Input
The first line contains an integer 0<n<=1000000, indicating that there are n groups of test data. Each of the following lines contains three integers, which are a, b, and n respectively.
Output
If there exist integers x and y such that the equation has a solution, output “Yes”; otherwise output “No”.
Sample Input
| |
Sample Output
| |
Source
Problem Analysis
The condition for the linear Diophantine equation to have integer solutions is
$n\%gcd(a,b)==0$
| |