# Convert Decimal To Irreducible Fraction

Posted: 3 Aug, 2020

Difficulty: Easy

#### You are given a real number, 'NUM'. You have to represent this number as an irreducible fraction of the form A/B, where 'A' and 'B' are the numerator and denominator respectively.

#### A fraction is called irreducible when the greatest common divisor (GCD/HCF) of the numerator and denominator is one.

##### Example :

```
Given 'NUM' : 1.75
Irreducible fraction can be represented as 7/4.
Note that 14/8 = 1.75 as well, but 14/8 is not an irreducible fraction.
```

##### Note :

```
In order to preserve precision, the real number will be given to you in the form of two strings : the integer part, and the fractional part.
The integer part will contain not more than 8 digits, whereas the fractional part will always contain 8 digits.
```

##### Input Format :

```
The first input line contains an integer 'T', the number of test cases.
Then 'T' test cases follow.
For each test case, the only input line contains a real number 'NUM', in the form of two single space-separated strings: the integer part and the fractional part.
```

##### Output Format :

```
The output for each test case contains two single space-separated integers 'A' and 'B', the numerator and denominator of the irreducible fraction representing 'NUM' respectively.
The output for each test case will be printed in a separate line.
```

##### Note :

```
You don't need to print anything. It has already been taken care of, just implement the given function.
```

##### Constraints :

```
1 <= T <= 10^5
0 < NUM < 10^8
Time Limit : 1 sec
```

SIMILAR PROBLEMS

First N

Posted: 14 Apr, 2022

Difficulty: Easy

Can You Print

Posted: 14 Apr, 2022

Difficulty: Easy

Print Name

Posted: 20 Apr, 2022

Difficulty: Easy

A Number Game

Posted: 23 Apr, 2022

Difficulty: Moderate

Pair Product Div by K

Posted: 15 May, 2022

Difficulty: Moderate

Pair Product Div by K

Posted: 15 May, 2022

Difficulty: Moderate