Detailed explanation can be find at this link

```
class Solution {
public:
bool canMeasureWater(int x, int y, int z) {
if (x + y < z) return false;
if (z <= 0 || x == z || y == z || x + y == z) return true;
return (__gcd(x, y) == 1);
}
};
```