程序设计在线评测(Online Judge)


问题 1023. -- 2011市赛题:Euclid

1023: 2011市赛题:Euclid

时间限制: 1 Sec  内存限制: 128 MB
提交: 60  解决: 23
[提交][状态][讨论版]

题目描述

Problem Description

When Euclid invented his Euclid Algorithm to calculate the greatest common divisor of two integers, he also wanted to solve a more complex problem of greatest common  fractional divisor(GCFD).

That is to say, You will be given two fractions. Please find the largest fraction which can be divided by both of the two fractions.

输入

The first line contains an integer T (T <= 100) indicating the number of test cases.

For each test case, there are one line contains two fractions described by standard form. The standard form is "numerater/denominator" and GCD(numerater,denominator) is equal to 1. For example, 2/1, 4/3 are in standard form.

(0 < numerater <= 1000, 0 < denominator <= 1000)

输出

For each test case, please output one line of the GCFD in standard form.

样例输入

2
1/2 1/3
7/2 21/4

样例输出

1/6
7/4

提示

本题属于简单题,通过分析可以想到:

只需要将两个分数通分,使他们的分母相同,然后求分子的最大公约数,

将其作为分子,最后进行约分即可。

来源

[提交][状态][讨论版]