problem $\sqrt{13}$
The decimal expansion of the square root of two is $1.\underline{4142135623}730…$ .
根号二的无限循环展开是 $1.\underline{4142135623}730…$ .
If we define $S(n,d)$ to be the the sum of the first $d$ digits in the fractional part of the decimal expansion of $\sqrt n$ , it can be seen that $S(2,10)=4+1+4+…+3=31$ .It can be confirmed that $S(2,100)=481$ .
如果我们定义 $S(n,d)$ 代表 $\sqrt n$ 的前 $d$ 位展开的各位数字和,可以得到 $S(2,10)=4+1+4+…+3=31$ .同理 $S(2,100)=481$ .
Find $S(13,1000)$ .
计算出 $S(13,1000)$ .
Note: Instead of just using arbitrary precision floats, try to be creative with your method.
注意:除了直接用高精度库函数之外,请发挥创造力用自己的办法算出来.
题解(spoiler)
最简单的一集.方法超级多.
- 使用Python的decimal库(前人留库,后人乘凉,不要重复造轮子).
- 模拟高精度,把13扩大好多好多倍然后手工模拟计算.
- 牛顿迭代(求导算切线)
- 泰勒展开(能手算的那种)
- 网上的手开根号大法(就是那个乘20啥啥的那个方法)
总之这个题非常简单,真就白给,拿到题先出的题解再出的代码.