import math
class Solution(object):
def isPowerOfThree(self, n):
"""
:type n: int
:rtype: bool
"""
if n < 1: return False
x = math.log(n,3)
return abs(round(x) - x) < 0.0000000000001
s=Solution()
print(s.isPowerOfThree(27))
[leetcode]#326. Power of Three
最新推荐文章于 2022-04-28 10:41:39 发布