Chinese Remainder (Two)

Computer Mathematics Hard 2 views
Back to Questions

Problem Description

Solve x ≡ a (mod m), x ≡ b (mod n) when m and n are coprime.

Input Format

Four integers a m b n.

Output Format

One integer smallest x.

Sample Test Case

Input:
2 3 3 5
Output:
8

Constraints

m,n coprime

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next