y*n
3 楼
还有什么好方法。二分好像不行吧。
l*i
6 楼
you can use binary search, because x^1/3 is monotonic
double cubicRoot(double x)
{
if 0 <= x and x <= 1, then set lo = 0, hi = 1
else if 1 < x, then set lo = 1, hi = x
// deal with negative x
then you can do binary search in [lo, hi]
Newton's method is likely faster
}
double cubicRoot(double x)
{
if 0 <= x and x <= 1, then set lo = 0, hi = 1
else if 1 < x, then set lo = 1, hi = x
// deal with negative x
then you can do binary search in [lo, hi]
Newton's method is likely faster
}
y*n
7 楼
不好意思,这个出啦不是SquareRoot 吗?
相关阅读
Largest Rectangle in Histogram马上就要签合同了,大家帮着看看这样的合同条件合理吗(注化工制药行业)汉诺塔为啥dfs可以解决?请教cracking the code interview两题是不是现在的offer下之前都要candidate口头答应啊请问谁了解ThousandEyes这个公司H-1B马上10月1日生效,可以晚点入职吗?上来求高手们指点条活路~~~问一下Form I-9的事求建议Refer Bazaarvoice NY Austin San Francisco Software Developer 的职位敢问三爷现在学什么呐?紧急紧急,急需一个MS degree,十个包子给真正有帮助的建议为什么擅长编程的主要是男人?为什么女人这方面相对弱这个behavioral的问题好难答谁要elelments of programming interviewimagong只支持java?有做SAP ERP 之类的吗 貌似很火吗?amazon选组再问一下EC2 OR AWS SECURITY准备跟800题大牛一起好好搞搞system design了。