leetcode ——29——Divide Two Integers
来源:互联网 发布:2016批量注册淘宝小号 编辑:程序博客网 时间:2024/04/29 19:15
Divide two integers without using multiplication, division and mod operator.
If it is overflow, return MAX_INT.
class Solution {public: int divide(int dividend, int divisor) { int sign = (dividend < 0) ^ (divisor < 0) ? - 1 : 1; long long res = 0, m = abs((long long)dividend), n = abs((long long)divisor); while(m >= n) { long long t = n, i = 1; while(t << 1 < m) { t <<= 1; i <<= 1; } m -= t; res += i; } if(sign < 0) res = -res; return res > INT_MAX ? INT_MAX : res; }};
0 0
- Leetcode 29 —— Divide Two Integers
- LeetCode——Divide Two Integers
- LeetCode——Divide Two Integers
- LeetCode——Divide Two Integers
- leetcode 029 —— Divide Two Integers
- LeetCode题解——Divide Two Integers
- Leetcode——29. Divide Two Integers
- leetcode ——29——Divide Two Integers
- <29>——Divide Two Integers
- Leetcode刷题记——29. Divide Two Integers(整数相除Divide two integers without using multiplication, division)
- Divide Two Integers ——解题报告
- leetcode_29——Divide Two Integers
- 算法系列——Divide Two Integers
- leetcode 29: Divide Two Integers
- LeetCode(29)Divide Two Integers
- [leetcode 29] Divide Two Integers
- [leetcode] 29 Divide Two Integers
- leetcode 29 Divide Two Integers
- 【论文笔记】One Millisecond Face Alignment with an Ensemble of Regression Trees
- win10 安装ubuntu on windows
- Linux内存点滴:用户进程内存空间
- 正则表达式-实现trim(str)方法,过滤字符串首尾空白
- 删除已经配置的类库和移除CocoaPods
- leetcode ——29——Divide Two Integers
- HDFS源码分析之LightWeightGSet
- 用Collections.sort方法对list排序
- 正则表达式初探-获取<p class='demo'>hello icketang</p>内部文案
- Android--音乐播放器
- 10倍效率的程序员的好习惯,你有几个?
- java注释中空格和换行符的处理
- OpenCV学习笔记(二十一)——绘图函数core OpenCV学习笔记(二十二)——粒子滤波跟踪方法 OpenCV学习笔记(二十三)——OpenCV的GUI之凤凰涅槃Qt OpenCV学习笔记(二十
- ICPCCamp 2016 Day 1 - A Aho-Corasick Automaton (主席树)