Código Fuente: https: //leetcode-cn.com/problems/water-and-jug-problem/comments/
idea es: binario lineal ecuación ax + by = z condiciones suficientes enteros de soluciones, X e Y es el mayor divisor z divisible común, si x + y <z vuelve directamente falsa, si el máximo común divisor == 0 devuelve falso.
public boolean canMeasureWater(int x, int y, int z) {
if (z == 0){
return true;
}
if (x + y < z){
return false;
}
int gcd = gcd(x, y);
if (gcd == 0){
return false;
}
return z % gcd == 0;
}