class Solution {
public:
int GCD(int a, int b) {
if(a < b) return GCD(b, a);
while(b) {
int c = a % b;
a = b;
b = c;
}
return a;
}
bool canMeasureWater(int x, int y, int z) {
if(x + y < z) return false;
if(x + y == z) return true;
int gcd = GCD(x, y);
if(gcd && z % gcd == 0) return true;
return false;
}
};
【leetcode 最大公约数 C++】365. Water and Jug Problem
猜你喜欢
转载自blog.csdn.net/m0_37454852/article/details/113861331
今日推荐
周排行