求一个数组的相加和最大的连续子数组 思路: 一直累加,只要大于0,就说明当前的“和”可以继续增大, 如果小于0了,说明“之前的最大和”已经不可能继续增大了,就从新开始, result=max{result+arr[i],arr[i]};显然,若result>0,则可以继续相加,否则,就重新开始。#i...
分类:
其他好文 时间:
2014-07-16 21:15:07
阅读次数:
202
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.思路:这道题主要是找出重叠结点和相同斜率之和。此时我们要判断有斜率和无斜率个数,并判断那个数量比较大,...
分类:
其他好文 时间:
2014-07-16 20:26:01
阅读次数:
123
数组元素是非负整数,0可以化为任意正整数,要求时间复杂度为O(n)觉得很奇怪的题目,遍历一次找到最值相减得到极差就行了,如果极差小于数组长度n,则元素相邻,否则不相邻bool is_adjacent(int* a, int n){ int min = 65535, max = 0; fo...
分类:
其他好文 时间:
2014-07-16 19:48:49
阅读次数:
177
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.题解:思路比较简单,每条直线都可以表示为y=kx+b,所以对于任意三点,如果它们共线,那么它们中任意两点的...
分类:
其他好文 时间:
2014-07-14 10:02:12
阅读次数:
187
A,B:很水,注意边界,话说HACK都是这些原因。C:R[I][J]:表示反转I-J能改变冒泡排序的次数; DP方程:dp[i][k]=max(dp[j][k],dp[j][k-1]+dp[j][i]) (0#include#include#include#include#includeusing ...
分类:
其他好文 时间:
2014-07-14 10:00:59
阅读次数:
191
mysql默认最大连接数是100,增加加默认MYSQL连接数的方法有两个方法一:进入MYSQL安装目录 打开MYSQL配置文件 my.ini(windows) 或 my.cnf(linux环境)查找 max_connections=100 修改为 max_connections=1000 服务里重起...
分类:
数据库 时间:
2014-07-13 12:33:19
阅读次数:
241
array(array(‘username’, ‘required’),array(‘username’, ‘length’, ‘min’=>3, ‘max’=>12),array(‘password’, ‘compare’, ‘compareAttribute’=>’password2′, ‘on...
分类:
其他好文 时间:
2014-07-13 11:57:16
阅读次数:
431
/*找出字符串中出现次数最多的字符,和最大次数*/function countMax(str){ var max = 0; // 记录出现的最大次数 var maxChar = ""; // 记录出现最多次数的字符 var counts = new Array(127); // 记录中...
分类:
其他好文 时间:
2014-07-13 11:42:05
阅读次数:
172
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2014题目大意:去掉一个最高分和一个最低分求平均数。 1 #include 2 int main() 3 { 4 double n,a,i,s,max,min; 5 while(scanf...
分类:
其他好文 时间:
2014-07-13 11:01:58
阅读次数:
202