All problems

Problem 347

Add Two Fractions

Easy · 10 pts · Math

Problem

Add the fractions A/B and C/D and print the result in lowest terms as P/Q. Lowest terms means P and Q share no common factor other than 1. The denominator Q must be positive; if the result is negative, the minus sign goes on the numerator. A whole-number result is still printed with its denominator, for example 2/1, and a zero result is printed as 0/1.

Input

Four integers A, B, C and D.

Output

Print the sum as P/Q in lowest terms.

Constraints

-1000000 <= A, C <= 1000000; 1 <= |B|, |D| <= 1000000

Example input

1 2 1 3

Example output

5/6

Explanation

1/2 + 1/3 = 3/6 + 2/6 = 5/6, and 5 and 6 have no common factor, so the answer is 5/6.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Fraction to Recurring Decimal Next: Perfect Square Check