class Solution {
public:
int divide(int dividend, int divisor) {
if(dividend==0)
return 0;
int tag=0;
if(dividend>0&&divisor<0||dividend<0&&divisor>0)
tag=1;
long long dividend1=dividend;
long long divisor1=divisor;
dividend1=abs(dividend1);
divisor1=abs(divisor1);
int res=0,final=0;
while(dividend1>=divisor1)
{
res=1;
long long sum=divisor1;
while(sum+sum<=dividend1)
{
res=res+res;
sum=sum+sum;
}
dividend1=dividend1-sum;
final=final+res;
}
if(tag==1)
return -final;
return final;
}
};