#include <stdio.h>
#pragma warning (disable:4996)
int count = 0;
void HalfStick(int stick, int x) {
while (stick > x) {
stick = stick / 2;
}
if (stick < x) {
x -= stick;
count++;
}
if (x == stick) {
count++;
return;
}
HalfStick(stick, x);
};
int main() {
int stick = 64;
int x;
scanf("%d", &x);
HalfStick(stick,x);
printf("%d", count);
}
'Code' 카테고리의 다른 글
[백준2292] 벌집 (0) | 2020.01.09 |
---|---|
[C Programming] 달팽이 배열 (0) | 2020.01.09 |
[C Programming] 에라토스테네스의 체 (0) | 2020.01.09 |
[Absolute C++] Ch4-16 (0) | 2019.09.19 |
[Absolute C++] Ch4-13 (0) | 2019.09.19 |