Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
301 B
2
Indexable
#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;
}