eolymp
bolt
Try our new interface for solving problems
Məsələlər

Repeating Decimals

Repeating Decimals

\includegraphics{https://static.e-olymp.com/content/15/1587adf0d00901682265da441aa460ef8473b34a.jpg} \includegraphics{https://static.e-olymp.com/content/3f/3f2821d695644f739378a58b633d62361bf620c3.jpg} \includegraphics{https://static.e-olymp.com/content/1e/1e75f10065d9ba5cee81e2abddfea34b48f8c4c3.jpg} \includegraphics{https://static.e-olymp.com/content/1e/1e75f10065d9ba5cee81e2abddfea34b48f8c4c3.jpg} A routine problem in basic mathematics is to convert fractions to decimals. For example, is just \textbf{0.5} while is \textbf{0.333...}, which is simply written as . The decimal \textbf{0.5} is said to be terminating while is repeating. Other examples of fractions which convert to repeating decimals are: \includegraphics{https://static.e-olymp.com/content/65/659d92d6f510f70e6c22d89774b2cf6a891ceee4.jpg} Your task is to determine the fraction in lowest terms that is equal to a given repeating decimal. \InputFile The input consists of one or more input lines. Each input line consists of a repeating decimal. The digits that repeat are enclosed in a pair of parentheses. The total number of digits in the decimal is at most \textbf{9}. \OutputFile The output consists of one or more lines with each line consisting of the given input followed by the equal sign and followed by the fraction in lowest terms. The fraction is displayed in the form \textbf{x / y}, where \textbf{x} is the numerator and \textbf{y} is the denominator.
Zaman məhdudiyyəti 5 saniyə
Yaddaşı istafadə məhdudiyyəti 128 MiB
Giriş verilənləri #1
0.(285714)
0.25(75)
4.1(6)
Çıxış verilənləri #1
0.(285714) = 2 / 7
0.25(75) = 17 / 66
4.1(6) = 25 / 6
Mənbə ACM ICM Philippines Multi-Provincial Programming Contest 2013