Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main()
- {
- ios::sync_with_stdio(false);
- cin.tie(nullptr); cout.tie(nullptr);
- unsigned long long n;
- cin >> n;
- auto s = bitset<128>(n);
- unsigned long long ans = 0;
- unsigned long long now = 1;
- bool fnd = s[s.size() - 1] == true;
- for(int i = s.size() - 2; i >= 0; i--){
- if(fnd == s[i]){
- fnd = !fnd;
- now++;
- }
- else {
- ans = max(ans, now);
- now = 1;
- fnd = s[i] != true;
- }
- }
- ans = max(ans, now);
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment