gpt4 book ai didi

java - 在 O(log) 时间内计算没有幂函数的 Java 幂

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:44:55 28 4
gpt4 key购买 nike

<分区>

这个问题是一位潜在雇主发给我的,我的回答显然不符合标准。谁能帮忙?

Implement a function that calculates power(A,B), where A and B are positive integers, assuming there is no power function in your programming language. Also, assume A and B are of Big Integer type so that there is no arithmetic overflow. What is the computational complexity of your function? Can you come up with a solution that runs with log(B) time?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com