Training: Math Pyramid (Math, Training)

Training: Math Pyramid (Math, Training)

题目描述

This is the first release of a math challenge.
You have to come up with the shortest solution (9 chars or less) for a geometric function.
And the story goes like:

Pharao momo wants a square-based pyramid, where all the eight edges are of the same length ‘a’.
Please support him with a formula to calculate the volume for a given side length.
Your co-workers already drew a sketch how the pyramid looks like from front-view:
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-8zy7SAcF-1620570329127)(typora-user-images/pyramid.png)]
Example Formula: a^3/3sqrt(aa)
Notation Hints: sqrt(), a^2, etc.

Enjoy!

Thanks go out to momo for the idea, Jinx for testing, paipai for a copy of EvalMath and Miles Kaufmann for writing the EvalMath class.

这是第一个发布的数学挑战。

你必须为一个几何函数想出最短的解(9个字符或更少)。

故事是这样的:

法老莫莫想要一个方形的金字塔,八条边都是相同长度的“a”。

请给他一个公式来计算给定边长下的体积。

你的同事已经画了一幅从正面看金字塔的草图:

pyramid.png

公式:一个^ 3/3 * sqrt (*)

符号提示:sqrt(), a^2,等等。

享受吧!

感谢momo的想法,Jinx的测试,paipai的EvalMath副本和Miles Kaufmann编写的EvalMath类。

画一个图就能很快就算出体积了(我想象力不够
在这里插入图片描述

直接百度体积计算公式也行。锥体积公式:

在这里插入图片描述

底面是边长a的正方形,底面积是a ^2,做两个直角三角形,
在这里插入图片描述
在这里插入图片描述

很容易求出高是
在这里插入图片描述
体积公式简化为
在这里插入图片描述

很容易得出sqrt(2)*a^3/6,但是题目有9字符的限制
简化:

  1. a^3/3*sqrt(2):13字符
  2. a^3/3*2^0.5:11字符 (python中就有类似的计算)
  3. a^3/18^0.5:10字符
  4. 18^-.5a^3:9字符 (0可以省略)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值