You can read the problem statement at here.
this problem can be solved using a brute-force approach i.e by doing a bfs on the states of the jars. we can also do a dfs to find a solution but since the problem asks us to find a minimum solution, we have to do bfs.
PS: another of way solving is by using extended euclid’s theorem.(from spoj comments.)