Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 1210
Reciprocals

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 infinitely.

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:

2
100
6250000
204800000000000000
8470329472543003390683225006796419620513916015625

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 =
0.5

1 / 100 =
0.01

1 / 6250000 =
0.00000016

1 / 204800000000000000 =
0.0000000000000000048828125

1 / 8470329472543003390683225006796419620513916015625 =
0.0000000000000000000000000000000000000000000000001180591620717411303424
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 the reciprocal.

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
Submit    Status