Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
301 B
1
Indexable
Never
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a, n, d;
	n = 0;
	string c;
	cin >> a;
	d = a;
	while (true){
		if (d == 1) {
			c += to_string(d % 2);
			n += 1;
			break;
		}
		c += to_string(d%2);
		if (d % 2 == 1) n += 1;
		d /= 2;
	}
	cout << n;
}