Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:
其他好文 时间:
2014-06-09 23:14:45
阅读次数:
264
【题目】
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
[3,4],
[6,5,7],
[4,1,8,3]
]
The minimum path sum from top to...
分类:
其他好文 时间:
2014-06-08 17:52:45
阅读次数:
235
Find the contiguous subarray within an array (containing at least one number) which has the largest sum....
分类:
其他好文 时间:
2014-06-08 15:54:08
阅读次数:
258
题目来源:Light OJ 1278 Sum of Consecutive Integers
题意:N拆分成连续整数和的方案数
思路:奇因数的个数
#include
#include
#include
#include
using namespace std;
//筛素数
const int maxn = 10000010;
bool vis[maxn];
int prime[10...
分类:
其他好文 时间:
2014-06-08 15:34:09
阅读次数:
295
在有关TCP连接的很多配置中,有很多选项有的配置
net.ipv4.tcp_rmem:这个参数定义了TCP接收缓冲(用于TCP接收滑动窗口)的最小值、默认值、最大值
net.ipv4.tcp_wmem:这个参数定义了TCP发送缓冲(用于TCP发送滑动窗口)的最小值、默认值、最大值
netdev_max_backlog:当网卡接收数据包的速度大于内核处理的速度时,会有一个队列保存这些数据包...
分类:
其他好文 时间:
2014-06-08 10:01:51
阅读次数:
523
随机数的事
总结随机数的那点事,不断总结中......
1.产生一个随机数
srand(time(0));
x=rand();//0~RAND_MAX-1
2.生成一个[a,b]之间的随机数
x=rand()%(b-a+1)+a;
3.以概率为Px%,Py%,Pz%(Px、Py、Pz均为整数且Px+Py+Pz=100)生成三个随机数
// This functio...
分类:
其他好文 时间:
2014-06-08 09:05:21
阅读次数:
304
点击打开链接
题意:给定牛的关系图,求其中一头牛与其他牛关系路程之和sum最小,然后输出 sum*100/(n-1)
floyd求任意两点间的最短路程
注意: inf不能太大,因为 f[i][k] + f[k][j] 做加法时可能会溢出!
#include
#include
const int maxn = 300 + 5;
const int inf = 1<<29;
int...
分类:
其他好文 时间:
2014-06-08 05:07:03
阅读次数:
181
HDU1002--A + B Problem II...
分类:
其他好文 时间:
2014-06-08 04:56:06
阅读次数:
242
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means th...
分类:
其他好文 时间:
2014-06-08 04:05:14
阅读次数:
315
题目 :Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2
解题思路:
给出一个数组合一个数,如果两个数的和等于所给的数,求出该两个数所在数组中的位置。
这个题也挺常见的,就是两个指针,从前后两个方向扫描。但是本题有以下几个需要的点:
1. 所给数组不是有序的;
2. 返回的下标是从1开始的,并且是原来无序数组中的下标;
3. 输入数组中可能含有重复的元素。
好了,把以上三点想到的话,做这个题应该不会有啥问题。
具体方法:把原...
分类:
其他好文 时间:
2014-06-08 02:14:06
阅读次数:
250