1318.cpp (359B)
1 class Solution { 2 public: 3 int minFlips(int a, int b, int c) { 4 int res = 0; 5 do { 6 int ba = a & 1, bb = b & 1; 7 if (c & 1) 8 res += !(ba | bb); 9 else 10 res += ba + bb; 11 a >>= 1, b >>= 1, c >>= 1; 12 } while (a > 0 || b > 0 || c > 0); 13 return res; 14 } 15 };