-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintfit.cpp
More file actions
35 lines (31 loc) · 810 Bytes
/
Copy pathintfit.cpp
File metadata and controls
35 lines (31 loc) · 810 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
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
bool isProperlyRepresented(unsigned int n) {
int left_shift = -1, right_shift = -1;
for (int shift = 0; shift < 9; ++shift) {
if (right_shift == -1 && ((n >> (31 - shift)) & 1)) {
right_shift = 31 - shift;
}
if (left_shift == -1 && ((n >> shift) & 1)) {
left_shift = shift;
}
if (left_shift != -1 && right_shift != -1)
break;
}
if (left_shift == -1 || right_shift == -1) {
return true;
}
if (right_shift - left_shift + 1 > 24) {
return false;
}
return true;
}
int main() {
unsigned int n;
while (cin >> n) {
cout << (isProperlyRepresented(n) ? "1\n":"0\n");
}
}