看起来没有用split()的精妙,但效率似乎更高。
while True:
try:
x=int(input())
str1=bin(x)
count=0
max_count=0
for i in str1:
if i=='1':
count+=1
else:
count=0
if count>max_count:
max_count=count
print(max_count)
except:
break