C++表示一个数的幂次数
讨论用另一个数的幂来表示一个数的问题。给定两个数,x和y。我们需要判断是否可以用x的幂来表示y,其中每个x的幂只能使用一次,例如
Input: x = 4, y = 11 Output: true Explanation: 4^2 - 4^1 - 4^0 = 11 Hence y can be represented in the power of x. Input: x = 2, y = 19 Output: true Explanation: 2^4 + 2^1 + 2^0 =19 Hence y can be represented in the power of x. Input: x = 3, y = 14 Output: false Explanation: 14 can be represented as 3^2 + 3^1 + 3^0 + 3^0 but we cannot use one term of power of x twice.登录后复制