luogu#P2399. non hates math

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.

Problem 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 nn.

Output Format

Output the reduced improper fraction form of the decimal nn.

1.32
33/25
1.(3)
4/3
1.0
1/1

Hint

The range of the input decimal is 00 to 10001000, and the number of characters after the decimal point does not exceed 99.
For 50%50\% of the testdata, there is no repeating part.

Translated by ChatGPT 5