编程介的小学生 2017-04-22 16:22 采纳率: 20.5%
浏览 862
已采纳

Reciprocals

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

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 关于下拉菜单选项关联的问题
  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R