Baekjoon/C++
[백준 1094번] 막대기
Yo-mi
2023. 10. 8. 03:04
#include <iostream>
using namespace std;
int cut(int x)
{
int stick = 64;
int shortStick = 64;
int n = 1;
while (x < stick)
{
shortStick = shortStick/2;
if (x <= (stick - shortStick))
{
stick -= shortStick;
n--;
}
n++;
}
return n;
}
int main()
{
int x;
cin >> x;
cout << cut(x);
}