题目:
思路:
直接看博文https://www.cnblogs.com/grandyang/p/5628836.html。
代码实现:
class Solution {
public:
int GCD(int a, int b){
while (b){
int t = b;
b = a % b;
a = t;
}
return a;
}
bool canMeasureWater(int x, int y, int z) {
if (x + y < z){
return false;
}
int ret = GCD(x,y);
return ret? z % ret == 0:1;
}
};
参考:
https://www.cnblogs.com/grandyang/p/5628836.html
https://leetcode.com/problems/water-and-jug-problem/discuss/83715/Math-solution-Java-solution