leetcode 326. Power of Three

比较通用的方法:

 

class Solution {
public:
    bool isPowerOfThree(int n) {
        if(n <= 0)
            return false;
        double res = log10(n) / log10(3);
        return (res - int(res) == 0) ? true : false;
    }
};

https://www.cnblogs.com/zhoudayang/p/5126842.html

https://blog.csdn.net/xsloop/article/details/50731987

 

posted @ 2018-09-15 22:12  有梦就要去实现他  阅读(100)  评论(0编辑  收藏  举报