Friday, December 16, 2011

Given N1, M1, N2 and M2, find the smallest non-negative integer X such that X % M1 = N1 and X % M2 = N2.


Example Inout
4 7 8 13
4 6 8 12
0 5 0 10 

Output:
60
-1
0

No comments :