eolymp
bolt
Try our new interface for solving problems
Problems

Fractional arithmetic

Fractional arithmetic

Write a program that realizes the addition, subtraction, multiplication and division of fractions. Format fractions in the input and output data: \begin{itemize} \item Number sign (written only when it changes the number of absence); \item Integer part of (zero integer part is not written, if the numerator and denominator); \item Blank (not written, unless there is an entire or fractional part); \item Numerator (if not zero); \item Sign / (if the numerator); \item Denominator (if the numerator). \end{itemize} Examples of representations of fractional numbers: \textbf{-7 3/4}, \textbf{8 1/2}, \textbf{-7/11}, \textbf{0}, \textbf{11}. \InputFile In the first line of input fraction (first operand), the second - a sign of operation ("+" - adds, "-" - subtract, "*" - multiplication, "/" - division) in the third line - fraction (second operand) . Both fractions can be reducible. The integer part can take the value from the range 0 .. 30000, the numerator and denominator can take values from 1 to 30000, by dividing the second operand is not zero. \OutputFile In a single line displays an irreducible proper fraction (result) in the above format.
Time limit 1 second
Memory limit 64 MiB
Input example #1
-3 1/6
+
2/4
Output example #1
-2 2/3