Leetcode 231 Power of Two 数论

同样是判断数是否是2的n次幂,同 Power of three

1 class Solution {
2 public:
3     bool isPowerOfTwo(int n) {
4         return (n > 0) && (((long long)1<<31) % n == 0);
5     }
6 };

 

posted @ 2016-03-01 16:24  Breeze0806  阅读(151)  评论(0编辑  收藏  举报