Python题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
import sys while True: try: n = int(input()) s = str(bin(n))[2:] i = 0 ans = [] while i < len(s): if s[i] == '1': res = 0 res += 1 j = i + 1 while j < len(s): if s[j] == '0': i = j ans.append(res) break else: j += 1 res += 1 ans.append(res) i += 1 print(max(ans)) except: break