Time Limit: 2 Seconds
Memory Limit: 65536 KB
The reciprocal of a positive integer is 1 divided by that integer. For example,
the reciprocal of 37 is 1/37. When the division is carried out to evaluate a
reciprocal in decimal form, the result often turns out to be an infinitely repeating
decimal. For example, 1/37 = 0.0270270270... where the group of digits 027 repeats
The subject of this problem, however, is a positive integer whose reciprocal,
when written in the decimal point format, ends after a finite number of digits.
Such a positive integer can be
a power of 10, or
a power of 2, or
a power of 2 followed by trailing zeros, or
a power of 5, or
a power of 5 followed by trailing zeros.
The input to your program will contain a list of such positive integers, one
per line, as shown in the following example:
Each positive integer in the input will
begin in column 1
be greater than 1
contain at most 72 digits.
It is easy to see that each of the first four numbers in the example shown here
falls into one of the five categories listed above. The fifth one happens to
be 5 raised to the 70th power.
For each number in the input, your program will write three lines of output:
one blank line,
one line that reproduces the given number from the input, in the format shown
in the sample output below,
one line that displays the exact value of the decimal representation of the
reciprocal of the given number.
For the input shown above, the output is the following:
Problem 4 by team x
1 / 2 =
1 / 100 =
1 / 6250000 =
1 / 204800000000000000 =
1 / 8470329472543003390683225006796419620513916015625 =
End of problem 4 by team x
Pay attention to every detail of the output format. In particular:
each non-blank line will begin in column 1;
the only blank lines are the ones specified above;
there is exactly one blank on each side of the "/" and one blank preceding
the equal sign;
there is exactly one 0 preceding the decimal point in the representation of
You may assume that the decimal representation of the reciprocal will not contain
more than 78 characters (including the leading 0 and the decimal point).
Source: Rocky Mountain 1999