鱼C论坛

 找回密码
 立即注册
查看: 2512|回复: 0

题目255:近似平方根

[复制链接]
发表于 2017-1-11 19:22:59 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 永恒的蓝色梦想 于 2020-8-31 07:49 编辑
Rounded Square Roots

We define the rounded-square-root of a positive integer n as the square root of n rounded to the nearest integer.

The following procedure (essentially Heron's method adapted to integer arithmetic) finds the rounded-square-root of n:

Let d be the number of digits of the number n.
If d is odd, set x0 = 2×10(d-1)/2.
If d is even, set x0 = 7×10(d-2)/2.
Repeat:

         p255_Heron.gif

until xk+1 = xk.

As an example, let us find the rounded-square-root of n = 4321.
n has 4 digits, so x0 = 7×10(4-2)/2 = 70.
         p255_Example.gif

Since x2 = x1, we stop here.
So, after just two iterations, we have found that the rounded-square-root of 4321 is 66 (the actual square root is 65.7343137…).

The number of iterations required when using this method is surprisingly low.
For example, we can find the rounded-square-root of a 5-digit integer (10,000 ≤ n ≤ 99,999) with an average of 3.2102888889 iterations (the average value was rounded to 10 decimal places).

Using the procedure described above, what is the average number of iterations required to find the rounded-square-root of a 14-digit number (1013 ≤ n < 1014)?
Give your answer rounded to 10 decimal places.

Note: The symbols &#8970;x&#8971; and &#8968;x&#8969; represent the floor function and ceiling function respectively.

题目:

我们定义近似平方根为与 n 的平方根最接近的正整数。

下面的过程将得到 n 的近似平方根(本质上来说,这是将古希腊数学家海伦的方法应用到整数运算上):

令 d 为数字 n 的数位。

如果 d 为奇数,令 x0 = 2×10(d-1)/2
如果 d 为偶数,令 x0 = 7×10(d-2)/2
重复:

         p255_Heron.gif

直到 xk+1 = xk

例如,当我们来求 n = 4321 的近似平方根时。

由于 n 是 4 位数,d=4,所以 x0 = 7×10(4-2)/2 = 70。

          p255_Example.gif

既然 x2 = x1,我们停止计算。

因此,在两次迭代后,我们得到 4321 的近似平方根为 66(事实上平方根为 65.7343137…)

使用这种方法所需要的迭代次数惊人的少。

例如,我们发现求 5 位数(10,000 ≤ n ≤ 99,999)的近似平方根所需的平均迭代次数为 3.2102888889 (平均值精确到小数点后 10 位)

使用上面介绍的方法,求 14 位数(1013 ≤ n < 1014)的近似平方根所需的平均迭代次数是多少?

答案精确到小数点后 10 位。


提示:符号 &#8970;x&#8971; 和 &#8968;x&#8969; 分别代表 x 的向下取整和向上取整。

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-2 22:16

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表