P2399 non hates math
Background
non is used to converting fractions into decimals, but in math they must write them as fractions and cannot convert them into decimals. Therefore, non turns to you, a programmer, to help convert decimals back to fractions.
Description
Given a decimal, convert it into an improper fraction.
There are two types of decimals (we do not consider infinite non-repeating decimals):
1. Terminating decimal;
2. Repeating decimal (the repeating part is given and enclosed in `()`).
Input Format
A decimal number $n$.
Output Format
Output the reduced improper fraction form of the decimal $n$.
Explanation/Hint
The range of the input decimal is $0$ to $1000$, and the number of characters after the decimal point does not exceed $9$.
For $50\%$ of the testdata, there is no repeating part.
Translated by ChatGPT 5