How do I use congruences to solve Diophantine equations?

For example 12x+25y=331.

I know this can be expressed as 12x=331(mod 25) but I don't know how to solve without just going through the numbers 1-25 to see which one works.

also how can I find the number of solutions for x^3=x^2(mod 50)?