class Stick { public: int pieces(int x) { int ret = 0; vector<int> v; v.push_back(64); while (v.back()) { v.push_back(v.back() / 2); } for (int i = 0; x && i < (int)v.size(); ++i) { if (x >= v[i]) x -= v[i], ++ret; } return ret; } };