Divide two integers without using multiplication, division and mod operator.
Returns the result of division of two integers without multiplication, division, and division. The result is also an integer.
If the divisor is 2, the Division operator is that the divisor binary represents moving one digit to the right.
Assume that the divisor is a and the divisor is B. because we do not know the quotient that A is divided by B, we can only try this sequence one by one from B, 2B, 4B, 8B ......
Deduct the values of the attempts from.
If A is greater than the number of sequences, A deducts this value, and the final result is that the quotient is added with the corresponding binary bit 1, and then tries the next number of sequences.
If a is less than the number of sequences, start from scratch until a is less than B.
Class Solution { Public : Int Divide ( Int Dividend, Int Divisor ){ Long Long A = llabs (( Long Long ) Dividend), B = llabs (( Long Long ) (Divisor), result = 0 ; While (A> = B ){ Long Long C = B; Int I = 0 ; While (A> = C) { -= C; Result + = 1 <I; ++ I; c = C < 1 ;}} If (Dividend> 0 & Divisor < 0 ) | (Dividend < 0 & Divisor> 0 ) Result =- Result; Return ( Int ) Result ;}};