题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
a = int(input())
res+=str(a%2)
import re
dp = re.findall("1+", res) # 匹配连续1的个数正则表达式
final = [len(i) for i in dp]
print(max(final))
res = ""
# 转换成二进制
while a:res+=str(a%2)
a = a//2
# 反转
res = res[::-1]
# 转换成二进制import re
dp = re.findall("1+", res) # 匹配连续1的个数正则表达式
final = [len(i) for i in dp]
print(max(final))