406192: GYM102307 F Fraction Formula

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Fraction Formulatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mr. Potato Head has been promoted and now is a math professor at the UNAL.

For his first course he is willing to teach hard subjects, so at the moment he is teaching how to add and subtract fractions.

To complete his course the students have to do a long series of exercises, each exercise corresponds to a valid formula containing only additions and subtractions of fractions.

Formally a valid formula is one of the following:

  • A fraction
  • $$$F_1+F_2$$$
  • $$$F_1-F_2$$$
  • $$$(F_1)$$$
where $$$F_1$$$ and $$$F_2$$$ are also valid formulas.

Mr. Potato Head knows that the exam would be impossible if fractions are too large or if they are negative, so he decides that for every fraction $$$a/b$$$, $$$0 \leq a \leq 100$$$ and $$$0 < b \leq 20$$$.

Can you pass the course of Mr. Potato Head?

Input

The input consists of several lines, each line contains a valid formula without spaces.

It is guaranteed that all lines contains valid formulas and the total number of characters in all formulas does not exceed $$$2*10^5$$$

Output

For each formula output a line with an irreducible fraction $$$a/b$$$, $$$b>0$$$ $$$-$$$ The solution of the corresponding formula

ExampleInput
1/2+1/3
1/5-2/10
1/2+(1/2-2/1)
Output
5/6
0/1
-1/1
Note

A fraction is irreducible if its numerator and denominator do not have common divisors greater than 1

加入题单

上一题 下一题 算法标签: