← 返回题库
中级

Radix

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve(____):
    n1 = str(____)
    n2 = str(____)
    tag = str(____)
    radix = int(____)
    if tag == '____':
        n1, n2 = n2, n1
    def to_decimal(____):
        result = ____
        for c in s:
            if c.isdigit():
                result = result * r + int(____)
            else:
                result = result * r + ord(____) - ord(____) + ____
        return result
    def find_radix(____):
        low = ____
        high = max(____)
        while low <= high:
            mid = (____) // ____
            val = to_decimal(____)
            if val == target:
                return mid
            elif val < target:
                low = mid + ____
            else:
                high = mid - ____
        return -____
    target = to_decimal(____)
    result = find_radix(____)
    print(____)

示例

输入
solve(6, 1, 110, 2)
期望输出
2
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码