该题目来源于 twitter 公司 2014 年面试题 deion:( b ild a pile of c bes ) yo r task is to constr ct a b ilding which will be a pile of n c bes. the c be at the bottom will have a vol me of n^3, the c be above will have vol me of (n-1)^3 and so on ntil the top which will have a vol me of 1^3. (你的任务是建造一个将是一堆n个立方体的建筑物. 底部的立方体将具有n ^ 3的体积,上面的立方体将具有(n-1)^ 3的体积,直到顶部的体积为1 ^ 3) yo are given the total vol me m of the b ilding. being given m can yo find the n mber n of c bes yo will have to b ild? (您将获得建筑物的总体积m. 给予m可以找到您将要构建的多维数据集的数量n?) the parameter of the f nction findnb (find_nb, find-nb, findnb) will be an integer m and yo have to ret rn the integer n s ch as n^3 + (n-1)^3 + ... + 1^3 = m if s ch a n exists or -1 if there is no s ch n. (函数findnb(find_nb,find-nb,findnb)的参数将为整数m,您必须返回整数n,例如n ^ 3 +(n-1)^ 3 + ... + 1 ^ 3 = 如果存在这种情况,或者如果没有这样的话,则为-1.) examples: 答案: 欢迎大家踊跃回答,把您认为最简洁,高效,有趣的答案,发送到猿助猿后台!与小编互动即有机会获得价值不菲的精美礼品哦~赶紧"躁"起来吧! 觉得本文有帮助?