Submit | All submissions | Best solutions | Back to list |
SUMFRAC - Sum of fractions |
Description
Given a list of rational numbers, find the sum in reduced form. A positive fraction is in reduced form if the numerator and denominator are positive integers that have no common divisors greater than 1. (For example, 2/4 in reduced form is 1/2).
Input
The first line is an integer N. (0 < N <= 5)
The next N lines will contain a rational number in the form A/B, where A and B are positive integers less than 500.
Output
Print the sum of the numbers in reduced form.
Examples
Input | Input | Input |
---|---|---|
2 1/2 1/3 |
2 5/10 2/6 |
3 3/4 6/5 342/8 |
Output | Output | Output |
5/6 |
5/6 |
447/10 |
Added by: | BYU Admin |
Date: | 2015-11-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 MAWK BC NCSHARP COFFEE DART FORTH GOSU JS-MONKEY JULIA KTLN OCT PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA |