Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

1.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, dashedName
id title challengeType videoUrl dashedName
5900f46d1000cf542c50ff7f 问题255圆角平方根 5 problem-255-rounded-square-roots

--description--

我们将正整数n的圆角平方根定义为n的平方根四舍五入到最接近的整数。

以下过程基本上是Heron的方法适用于整数运算找到n的舍入平方根设d是数字n的位数。如果d为奇数则设置x0 = 2×10d-1/ 2。如果d是偶数则设置x0 = 7×10d-2/ 2。重复

直到xk + 1 = xk。

举个例子让我们找到n = 4321.n的圆角平方根有4个数字所以x0 = 7×104-2/2 = 70.由于x2 = x1我们在这里停止。因此经过两次迭代后我们发现4321的圆角平方根为66实际平方根为65.7343137 ......)。

使用此方法时所需的迭代次数非常低。例如我们可以找到5位整数的圆角平方根10,000≤n≤99,999平均迭代次数为3.2102888889平均值四舍五入到10位小数

使用上述过程找到14位数字的圆角平方根1013≤n<1014所需的平均迭代次数是多少将您的答案四舍五入到小数点后10位。

注意符号⌊x⌋和⌈x⌉分别代表楼层功能和天花板功能。

--hints--

euler255()应返回4.447401118。

assert.strictEqual(euler255(), 4.447401118);

--seed--

--seed-contents--

function euler255() {

  return true;
}

euler255();

--solutions--

// solution required