1611.cpp (265B)
1 class Solution { 2 public: 3 int minimumOneBitOperations(int n) const { 4 bitset<32> res, num(n); 5 res[31] = num[31]; 6 for (int i = 30; i >= 0; i--) { 7 res[i] = res[i + 1] ^ num[i]; 8 } 9 return res.to_ulong(); 10 } 11 };