题解 | #求最大连续bit数#
求最大连续bit数
http://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
貌似例题输出不对?
def ten2two(ten): result = "" while ten != 0: result = str(ten % 2) + result ten = ten // 2 return result while True: try: n = int(input()) res = list(str(ten2two(n))) td = [] x = 0 for n, i in enumerate(res): if i == '1': x += 1 if n == len(res)-1: td.append(x) else: if x != 0: td.append(x) x = 0 if td: print(max(td)) else: print(0) except EOFError: break