-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path597.cpp
More file actions
46 lines (37 loc) · 794 Bytes
/
597.cpp
File metadata and controls
46 lines (37 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <algorithm>
#include <deque>
int main() {
int n;
std::cin >> n;
if(n < 2) {
std::cout << n << "\n";
return 0;
}
std::deque<int> binRepres;
while(n > 0) {
binRepres.push_front(n % 2);
n /= 2;
}
/*
for(unsigned i = 0; i < binRepres.size(); i++)
std::cout << binRepres[i] << " ";
std::cout<< "\n";
*/
int maxNum = 0;
for(unsigned i = 0; i < binRepres.size(); i++) {
int val = 0;
std::rotate(binRepres.begin(), binRepres.begin() + 1, binRepres.end());
/*
for(unsigned i = 0; i < binRepres.size(); i++)
std::cout << binRepres[i] << " ";
std::cout<< "\n";
*/
for(unsigned j = 0; j < binRepres.size(); j++) {
val = val * 2 + binRepres[j];
}
maxNum = std::max(maxNum, val);
}
std::cout << maxNum << "\n";
return 0;
}