326. 3的幂

题目

代码

class Solution {
public:
    bool isPowerOfThree(int n) {
        //3的19次方是3的倍数的最大值
        //用换底公式
        return n > 0 && (log(INT_MAX)/log(3)) % n == 0;
    }
};
https://github.com/li-zheng-hao
原文地址:https://www.cnblogs.com/lizhenghao126/p/11053615.html