#include #include int sumTatakuT( int n ) { if( n < 0 ){ n = -n; } int distance = 0; bool exponent2 = true; if( n < 2 ){ return distance; } do{ ++distance; if( n % 2 && n > 1){ exponent2 = false; } }while( ( n /= 2 ) > 1 ); return (exponent2 ? distance : distance + 1); } int main() { std::cout << "number : "; std::string strn; std::cin >> strn; int n = std::stoi( strn ); std::cout << sumTatakuT( n ) << "\n"; return 0; }