判断 一个数是不是 4 的幂
class Solution { public: bool isPowerOfFour(int num) { if(num<=0) return false; else { int test = 0x55555555; int MaxPowerOfFour = 0x01<<30; return MaxPowerOfFour % num ? false:((test&num)==num?true:false); } } };
class Solution { public: bool isPowerOfFour(int num) { if(num<=0) return false; else { int test = 0x55555555; int MaxPowerOfFour = 0x01<<30; return MaxPowerOfFour % num ? false:((test&num)==num?true:false); } } };