maximizing-xor: c++ implementation

This commit is contained in:
Dmitry Kokorin 2016-09-12 16:22:59 +03:00
parent 1bac478cb3
commit eedc533521
2 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,22 @@
#include <iostream>
#include <stdint.h>
using namespace std;
int main()
{
uint32_t L, R, M;
cin >> L >> R;
M = L^R;
M--;
M |= M >> 1;
M |= M >> 2;
M |= M >> 4;
M |= M >> 8;
M |= M >> 16;
cout << M;
return 0;
}