用减法可能会超时,但可以用二分
class Solution {
public:
int divide(int d1, int d2) {// d1/d2
if(d1==0)
return 0;
if(d2==1)
return d1;
if(d2==-1)
...
分类:
其他好文 时间:
2014-06-29 07:22:02
阅读次数:
208
归并排序是建立在归并操作上的一种有效的排序算法。该算法是採用分治法(Divide and
Conquer)的一个很典型的应用。首先考虑下怎样将将二个有序数列合并。这个很easy,仅仅要从比較二个数列的第一个数,谁小就先取谁,取了后就在相应数列中删除这个数。然后再进行比較,假设有数列为空,那直接将还有...
分类:
其他好文 时间:
2014-06-11 21:52:36
阅读次数:
289
Divide two integers without using
multiplication, division and mod operator.
其实刚开始看到这道题的时候,感觉应该是略简单。但真正开始写的时候发现了很多错误。 最开始的想法就是divisor一个一个加上去直到大于divide...
分类:
其他好文 时间:
2014-06-11 12:17:22
阅读次数:
274
package chap04_Divide_And_Conquer;import static
org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;/** * 矩阵相乘的算法 *
* @author xiaojintao....
分类:
其他好文 时间:
2014-06-09 16:12:24
阅读次数:
273
题目链接题意: 给出 n * n的矩阵,要求将矩阵顺时针旋转90°(不使用额外空间) 1 /* 2
Basically, divide the array into 4 along the diagonals, 3 then for each element
in the top ...
分类:
其他好文 时间:
2014-06-09 15:28:14
阅读次数:
280
package chap04_Divide_And_Conquer;import static
org.junit.Assert.*;import java.util.Arrays;import org.junit.Test;/** * 算反导论第四章
4.1 最大子数组 * * @author ....
分类:
其他好文 时间:
2014-06-07 20:21:38
阅读次数:
212
Let d(n) be defined as the sum of proper divisors of n (numbers less than
n which divide evenly into n).
If d(a) = b and d(b) = a, where a
b, then a and b are an amicable pair and each of a and
b...
分类:
其他好文 时间:
2014-06-07 13:40:53
阅读次数:
226
Divide two integers without using
multiplication, division and mod operator. 1 class Solution { 2 public: 3 int
divide(int dividend, int divisor) ...
分类:
其他好文 时间:
2014-06-06 17:40:07
阅读次数:
193
问题描述:
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
If d(a) = b and d(b) = a, where a b, then a and b are
an amicable pair and each ...
分类:
编程语言 时间:
2014-06-02 12:31:42
阅读次数:
298
归并排序是建立在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and
Conquer)的一个非常典型的应用。 归并操作(merge),也叫归并算法,指的是将两个已经排序的序列合并成一个序列的操作。归并排序算法依赖归并操作。
归并操作步骤如下:(两个有序序列分别用A[aMax]、B...
分类:
其他好文 时间:
2014-06-02 01:19:11
阅读次数:
349