I first wrote a solution that iff gcd(a,b)|c then answer exists, but realized that we need to have non negative integral solution.
So i checked the editorial. It mentioned this:
Editorial : The problem is to find if there exists a solution to the equation: ax + by = c where x and y are both positive integers. The limits are small enough to try all values of x and correspondingly try if such a y exists. The question can also be solved more efficiently using the fact that an integral solution to this problem exists iff gcd ( a , b )| c . We just have to make one more check to ensure a positive integral solution.
Now my question how can i make this check to ensure a positive integral solution?