← Back to List

1094번: 막대기 ↗

Solutions

C++14
153 B | 153 chars
#include <iostream>
using namespace std;
int A,Cnt,K;
int main()
{
	cin>>A;
	while(A>0)
	{
		K=1;
		while(K*2<=A) K*=2;
		Cnt++;
		A-=K;
	}
	cout<<Cnt;
}