/* Description
Kong Rong has no siblings. At the weekend, he went to seven siblings, including cousin Kong Ming, Tang Jie Kong Ru, and Tang di KONG Wei, to play at home.
Kong Rong's mother bought 8 pears for the children to eat. As a result, Tong, a yellow dog, moved away from the Naughty Dog, and Xin, a big cat, secretly hid one.
Kong Rong snatched the remaining six pears, and his mother stopped him and said that he would eat them equally. Kong Rong is not happy. How do eight people divide 6 pears?
Mom said that the score can be used to solve this problem. Kong Rong learned the score, saying that each pear should be cut into eight equal parts, and each person can take six parts.
Mom said there is no need to cut so many pieces. Each pear slices 4 equal pieces, and each person takes 3 pieces. Kong Rong is confused. Kong Ming said, I will teach you.
Therefore, Kong Ming explained to Kong Rong the simplification of scores.
The score can be simplified to the simplest form. For example, 12/20 can be reduced to 6/10 and 3/5, but 3/5 is the simplest form. 100/8 can be reduced to 50/4 and 25/2,
25/2 is the simplest form. To reduce the difficulty, you do not need to simplify the false score (for example, 7/2) to a score (3 1/2) form.
* Write a program to help Kong Rong simplify any score into the simplest form.
* Input
The first row of the input data indicates the number of scores to be reduced. Starting from the second row, each row has two integers, m, n (1 <= m, n <= 10000 ), m indicates the numerator, and n indicates the denominator.
* Output
For each score, the simplest form after the simplification of the output score.
* Sample input
3
8 14
219 111
210 35
* Sample output
4/7
73/37
6/1
*/
# Include <iostream>
Using namespace std;
Int g (int x, int y); // calculates the maximum approximate number.
Int main ()
{
Int I, j, a [10], B [10];
Cin> j;
For (I = 0; I <j; I ++) // input molecules, denominator
{
Cin> a [I];
Cin> B [I];
}
For (I = 0; I <j; I ++) // output molecule, denominator
{
Int t;
T = g (a [I], B [I]);
A [I] = a [I]/t;
B [I] = B [I]/t;
Cout <a [I] <'/' <B [I] <endl;
}
Return 0;
}
Int g (int x, int y) // calculates the maximum approximate number.
{
Int r;
While (y> 0)
{
R = x % y;
X = y;
Y = r;
}
Return x;
}
Running result:
Speaking: simplifying the score is actually the problem of finding the maximum common divisor of two numbers.
Think about it. We can also calculate the maximum number of common approx ..