MDantas's blog

By MDantas, 14 years ago, In English

Given four integers N,M,x,y ( 1 <= x,y,N,M <= 10^9 ), what's the minimum value of T such that:

T ≡ x mod N

T ≡ y mod M

Can somebody help me?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
14 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it
»
14 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

T=N*k+x, T=M*p+y => N*k+x=M*p+y <=> N*k-M*p=y-x. Now it's Extended Euclid's algorithm problem. Use it to find k and p.