class Solution { public: int NumberOf1(int n) { int a = 1; int nums = 0; while (a != 0) { if (n == (n | a)) nums++; a <<= 1; } return nums; } };