碎碎念
终于是easy题了......连续被电了两天的hard(昨天的我还没发文)
题干
确认输入的数字是4的平方数(也就是4^x)
解题思路
基本上就是mod
然后一直除以四,最后除尽就是4的平方数
class Solution: def isPowerOfFour(self, a: int) -> bool: if a < 1: return False while a > 1: if a % 4 != 0: return False a = a // 4 return True
里面加一个counter甚至还可以计算出他是四的几倍数