Linear Diophantine Equation
Read the first answer and you can solve this problem.\nhttps://math.stackexchange.com/questions/145346/diophantine-equations-with-multiple-variables\n\nAs a sid
Read the first answer and you can solve this problem.\nhttps://math.stackexchange.com/questions/145346/diophantine-equations-with-multiple-variables\n\nAs a side note, this equation is also used in the two water jars problem (https://leetcode.com/problems/water-and-jug-problem/). Also, this is one of the most frequently used mathematics concept (along with sieve) in Codeforces/coding contests in general, so it\'s worth learning. \n\n```\nbool isGoodArray(vector<int>& nums) {\n        int hcf = nums[0];\n        for (auto x: nums)\n            hcf = gcd(x, hcf);\n        return hcf == 1;\n    }\n```
['Math']