Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using ll = long long;
- using ld = long double;
- const ll INF = 2*1e9;
- //Acımasızca geçip giden zamandan
- //Geriye kalan sadece yalnızlıklarımız
- int main(){
- ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("input.txt","r",stdin);
- ll n; cin>>n;
- string bin = "";
- while(n > 0){
- int q = n % 2;
- bin = to_string(q) + bin;
- n/=2;
- }
- vector<string> v;
- v.push_back(bin);
- for(int i = 1;i<(int)bin.size();i++){
- bin += bin[0];
- bin = bin.substr(1,(int)bin.size());
- v.push_back(bin);
- }
- sort(v.begin(),v.end());
- bin = v[v.size()-1];
- n = 0;
- for(int i = 0;i<(int)bin.size();i++){
- if(bin[i] == '1'){
- n += pow(2,(int)bin.size() - i - 1);
- }
- }
- cout << n << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement