摘要: 2的幂次 最佳解法 如果一个数是2的次方数的话,根据上面分析,那么它的二进数必然是最高位为1,其它都为0,那么如果此时我们减1的话,则最高位会降一位,其余为0的位现在都为变为1,那么我们把两数相与,就会得到0,用这个性质也能来解题,而且只需一行代码就可以搞定,如下所示: 递归 位运算 3的幂次 题目 阅读全文
posted @ 2018-01-16 13:25 Sherry_Yang 阅读(117) 评论(0) 推荐(0) 编辑
摘要: happy number Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any po 阅读全文
posted @ 2018-01-16 10:29 Sherry_Yang 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 所谓丑数,是指质因子只能是2,3,5中的。1认为也是丑数。 阅读全文
posted @ 2018-01-16 10:12 Sherry_Yang 阅读(112) 评论(0) 推荐(0) 编辑