classSolution { public: intdivide(int x, int y){ typedeflonglong LL; LL res = 0, k = 1; if(x < 0 && y > 0 || x > 0 && y < 0) k = -1; LL a = abs((LL)x), b = abs((LL)y); vector<LL> p; for(LL i = b; i <= a; i += i) p.push_back(i), cout << i << endl;
for(int i = p.size() - 1; i >= 0; i--){ if(p[i] <= a){ res += 1ll << i; a -= p[i]; } }
if(k == -1) res = -res; if(res < INT_MIN || res > INT_MAX) res = INT_MAX; return res; } };