Advertisement
Guest User

4

a guest
Apr 9th, 2020
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main() {
  5. int n;
  6.   cin>>n;
  7.   int bitAmount = 0;
  8.   while (n) {
  9.     bitAmount += n % 2;
  10.     n /= 2;
  11.   }
  12.   if (bitAmount == 1)
  13.     cout<<"YES";
  14.   else
  15.     cout<<"NO";
  16.   return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement