题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
#include <iostream> using namespace std; int main() { int input; while (cin >> input) { int x = 0; int count = 0; while (input / 2 != 0) { if (input % 2 == 1) { count++; } if (input % 2 == 0) { count = 0; } if (x < count) { x = count; } input /= 2; } count++; if (x < count) { x = count; } cout << x << endl; } } // 64 位输出请用 printf("%lld")