Code

[백준 1094] 막대기

BIGFROG 2020. 1. 9. 18:42
#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);

}