fork(1) download
  1. #include <iostream>
  2. #include <bitset>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main(void) {
  8. unsigned int num;
  9. while (cin >> num) {
  10. int x = num >> 1;
  11. int y = (x ^ num);
  12. cout << bitset<8>(num) << (y & (y+1) ? ": false" : ": true") << endl;
  13. }
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 16064KB
stdin
1
2
3
5
10
11
21
42
43
44
45
170 
stdout
00000001: true
00000010: true
00000011: false
00000101: true
00001010: true
00001011: false
00010101: true
00101010: true
00101011: false
00101100: false
00101101: false
10101010: true