#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
while (cin >> n) {
int count = 0;//记录每次统计的连续1的个数
int max_count = 1;//记录最大连续1的个数
while (n) {
if (n % 2 == 1){//最后一位为1
count++;
max_count = max(max_count, count);//更新最大值
}
else //遇到不为1
count = 0;//从0开始
n /= 2; //去掉最后一位
}
cout << max_count << endl;
}
return 0;
}

京公网安备 11010502036488号