题解 | #求最大连续bit数#
求最大连续bit数
https://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
#include <iostream> #include <algorithm> using namespace std; int main() { int n, mx = 0, temp = 0; cin >> n; while (n) { if (n % 2 == 1) { temp++; mx = max(mx, temp); } else temp = 0; n = n >> 1; } cout<<mx; }