Ուղարկել | Բոլոր լուծումները | Լավագույն լուծումները | Վերադառնալ ցուցակին |
ACM_0123 - REPEATING DECIMALS |
A routine problem in basic mathematics is to convert fractions to decimals. For example, 1/2 is just 0.5 while 1/3 is 0.333..., which is simply written as 0.(3) . The decimal 0.5 is said to be terminating while 0.(3) is repeating. Other examples of fractions which convert to repeating decimals are:
2/7=0.(285714)
17/66=0.25(75)
25/6=4.1(6)
3401/333=10.(213)
Your task is to determine the fraction in lowest terms that is equal to a given repeating decimal.
Input
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 9.
Output
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 x / y, where x is the numerator and y is the denominator.
Examples
№ |
stdin |
stdout |
1 |
0.(285714) 0.25(75) 4.1(6) |
0.(285714) = 2 / 7 0.25(75) = 17 / 66 4.1(6) = 25 / 6 |
Ավելացրեց. | Հրանտ Հովհաննիսյան |
Ամսաթիվ. | 2014-02-06 |
Ժամանակի սահմանափակումը. | 1s |
Ծրագրի տեքստի սահմանափակումը. | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Լեզուներ. | Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE |
Աղբյուրը. | Philippines Multi-Provincial 2013.B |