#A. 分数求和

    Type: Default 1000ms 256MiB

分数求和

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

输入nn个分数并对他们求和,并用最简形式表示。

所谓最简形式是指:分子分母的最大公约数为11;若最终结果的分母为11,则直接用整数表示。

如:56103\frac{5}{6}、\frac{10}{3} 均是最简形式,而36\frac{3}{6}需要化简为21\frac{2}{1}31\frac{3}{1}需要化简为33

分子和分母均不为00,也不为负数。

输入

第一行是一个整数nn,表示分数个数,1n1001\le n\le100

接下来nn行,每行一个分数,用“p/qp/q”的形式表示,不含空格,ppqq均不超过1010

输出

输出只有一行,即最终结果的最简形式。若为分数,用“p/qp/q”的形式表示。

Samples

2
1/2
1/3
5/6

限制

1n1001\le n\le100

1p,q101\le p,q \le 10

XCPC 24寒假冬令营 练习5

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
3
Start at
2024-2-26 3:00
End at
2024-3-7 3:00
Duration
240 hour(s)
Host
Partic.
1