标签:class res div iso tco max long etc int
class Solution { public: int divide(int dividend, int divisor) { long long res = 0; long long m = abs((long long)dividend), n = abs((long long)divisor); if (m < n) return 0; long long t = n, p = 1; while (m > (t << 1)) { t <<= 1; p <<= 1; } res += p + divide(m - t, n); if ((dividend < 0) ^ (divisor < 0)) res = -res; return res > INT_MAX ? INT_MAX : res; } };
leetcode 29 Divide Two Integers
标签:class res div iso tco max long etc int
原文地址:http://www.cnblogs.com/wangkun1993/p/6390319.html