LeetCode375 水壶问题
3a+5b=4
a=-2,b=2
贝祖定理:ax+by=z 有解当且仅当 z 是 x,y 的最大公约数的倍数
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
class Solution {
public:
bool canMeasureWater(int x, int y, int t) {
if(x+y<t) return false;
return t%gcd(x,y)==0;
}
};