600. Non-negative Integers without Consecutive Ones
这题的递推公式实在是太tricky了。。。。
class Solution(object):
def findIntegers(self, num):
"""
:type num: int
:rtype: int
"""
x, y = 1, 2
res = 0
num += 1
while num:
if num & 1 and num & 2:
res = 0
res += x * (num & 1)
num >>= 1
x, y = y, x + y
return res