#PROBLEM LINK:
contest
#PREREQUISITES:
Greatest common divisors.
#Problem:
Given a , b , c in the equation ax+by=c; The problem is to determine if there exists
at least one solution for some integers value of x and y where x, y may be negative or
non-negative integers.
#Explanation:
We can show this like this:
[ax + by = c]
has integer solution x0,y0 implies GCD(a,b)/c. Factoring out GCD(a,b) from each side gives
[\frac{1}{GCD(a,b)}(ax+by) = \frac{1}{GCD(a,b)}c]
which must still have an integer solution as GCD(a,b) obviously divides both a and b. If GCD(a,b) does not divide c there is no integer solution.
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
scanf("%d" , &t);
for(int i = 1 ; i <= t ; i++){
int a , b ;
float c;
scanf("%d %d %f" , &a , &b , &c);
// cin >> a >> b >> c;
int temp = __gcd(a , b);
if(ceil(c / temp) == floor(c/ temp))
printf("Case %d: Yes\n" , i);
else
printf("Case %d: No\n" , i);
}
}