231. Power of Two

来源:互联网 发布:淘宝自动下架的原因 编辑:程序博客网 时间:2024/05/22 04:26

Given an integer, write a function to determine if it is a power of two.

Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.

class Solution {public:    bool isPowerOfTwo(int n) {    if(n<=0) return 0;int count=0;while(n){if(n%2==1) count++;if(count>1) return false;n/=2;}return true;    }};


阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 鸡饲料厂家 鸭饲料价格 批发鸡饲料 饲料鱼粉 鸭饲料厂家 蛋白质饲料 猪吃的饲料 饲料诱食剂 鸡饲料机械 小型鱼饲料 羊饲料厂家 精饲料 鱼粉饲料 饲料网站 大北农饲料 饲料蛋白 饲料包装 鱼饲料厂家 饲料油价格 电动饲料车 饲料车价格 饲料 价格 鱼饲料品牌 饲料饲料 饲料草 饲料行业 希望饲料 俄罗斯饲料菜 创造与魔法饲料 创造与魔法饲料大全图 东北饲料信息网 中国饲料原料信息网 中国饲料工业信息网 饲料原料信息网 中国饲料信息网 饲料工业信息网 饲料原料价格信息网 养猪什么饲料好 饲料生产厂家 仔猪饲料添加剂 饲料有限公司