You are viewing a single comment's thread. Return to all comments →
int n; cin >> n; int count=0,pre=0; while(n!=0) { if(n%2) count++; else { if(count>pre) pre=count; count=0; } n/=2; } if(count>pre) pre=count; cout<<pre;
Seems like cookies are disabled on this browser, please enable them to open this website
Consecutive 1's in Binary Numbers
You are viewing a single comment's thread. Return to all comments →