Baekjoon 1094
막대기


QUESTION ❔



CODE ⌨️

#include <iostream>

using namespace std;

int X, ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> X;

	while (X > 0)
	{
		if (X & 1) ans++;

		X >>= 1;
	}

	cout << ans << "\n";

	return 0;
}



RESULT 💛



SIMPLE DISCUSSION ✏️

Bitmasking 관련 문제였다.



SOURCE 💎

Baekjoon_Link 👈 Click here


*****
NOT A TALENT ❎ NOT GIVING UP ✅
CopyRight ⓒ 2022 DCherish All Rights Reserved.