leetcode 326. Power of Three
Given an integer, write a function to determine if it is a power of three.
判断一个数,是不是3的n次幂。直接换底公式求解
class Solution {
public:
bool isPowerOfThree(int n) {
double x = log10(n) / log10(3.0);
if (x == int(x)) return true;
return false;
}
};
原文地址:http://www.cnblogs.com/pk28/
与有肝胆人共事,从无字句处读书。
欢迎关注公众号:
欢迎关注公众号: