int a[Max],n; void build(int t) { int Min=a[t]; int l=2*t,k=t; int r=2*t+1; if(r<=n&&a[r]<Min) { Min=a[r]; k=r; } if(l<=n&&a[l]<Min) { Min=a[l]... ...
分类:
其他好文 时间:
2018-06-01 17:39:16
阅读次数:
149
一元运算符Java的一元运算符有++(自加)、--(自减) 二元运算符Java的二元运算符有+(加)、-(减)、*(乘)、/(除)、%(取余数)。三元运算符true?value1:value2;例: int a=0x10 , b=010 , max ;max=a>b ? a : b ; ...
分类:
其他好文 时间:
2018-05-31 00:33:15
阅读次数:
216
class Solution { public: int splitArray(vector& nums, int m) { int _max = -1, _sum = 0; for (auto n : nums) { if (n > _max) _max = n; _sum += n; ... ...
分类:
其他好文 时间:
2018-05-27 16:25:23
阅读次数:
146
class ArrayTool{ //最大值 public static int getMax(int[] arr) { int max=0; for (int x=0;x<arr.length ;x++ ) { if (arr[x]>arr[max]) { max =x; } } return a ...
分类:
编程语言 时间:
2018-05-26 15:30:49
阅读次数:
154
#include using namespace std; #define Max 3 #define mod 10000 int m; //m阶矩阵 struct Matrix { int m[Max][Max]; }; Matrix Mul(Matrix a,Matrix b) { Matrix... ...
分类:
其他好文 时间:
2018-05-23 22:10:23
阅读次数:
113
Recursion: 时间O(n) 空间O(h) 因为要找最长的连续路径,我们在遍历树的时候需要两个信息,一是目前连起来的路径有多长,二是目前路径的上一个节点的值。我们通过递归把这些信息代入,然后通过返回值返回一个最大的就行了。 ...
分类:
其他好文 时间:
2018-05-23 11:57:56
阅读次数:
163
class Solution { public: int minSubArrayLen(int s, vector& nums) { int w = 0, _sum = 0, res = INT_MAX; for (int i = 0; i = s) { res = min(res, i-w+1);... ...
分类:
其他好文 时间:
2018-05-21 14:28:29
阅读次数:
138
int的最大值是多少?加一呢?乘2呢? 第一个问题我想大多数人都知道,不知道后两个有多少人研究过。 首先上一段代码: 运行结果 int int_max 2147483647int_max+1 2147483648int_min 2147483648int_min-1 2147483647int_ma ...
分类:
编程语言 时间:
2018-05-17 13:30:53
阅读次数:
153
#include using namespace std; //欧几里德算法求两个非负整数的最大公约数 int getDivisor(int a,int b) { int max,min; max = a; min = b; //两数中大数模小数,若结果不为0,则舍弃大数 ,把小数和模运算的结果分出... ...
分类:
编程语言 时间:
2018-05-10 23:42:27
阅读次数:
163
``` include using namespace std; int n, m, t; const int INF = 0x3f3f3f3f; int a[1005],Max[1005],Min[1005]; void dfs(int d, int s) { for(int i=1; i=a[i ...
分类:
其他好文 时间:
2018-05-08 22:20:39
阅读次数:
161