一、字典结构 Redis中字典采用hash表结构,如下: table是一个数组,每个元素指向一个dictEntry结构。size表示hash表大小,used表示使用的大小。一个size=4的空hash表如下: dictEntry是一个key-value pair, 定义为: next指针用于解决ha ...
分类:
其他好文 时间:
2017-07-25 00:53:07
阅读次数:
188
一.解释: pair是一种模板类型,其中包含两个数据值,两个数据的类型可以不同。如果一个函数有两个返回值的话,如果是相同类型,就可以用数组返回,如果是不同类型,就可以自己写个struct ,但为了方便就可以使用 c++自带的pair ,返回一个pair,其中带有两个值。除了返回值的应用,在一个对象有 ...
分类:
编程语言 时间:
2017-07-24 23:48:01
阅读次数:
247
题目:https://cn.vjudge.net/problem/UVA-11752 题解:这里只讨论处理越界的问题。 因为题目最上界是 264-1。 我们又是求次幂的。 所以当我们就可以知道 i 的时候的界限 limit = 264-1 / i。如果刚好前一个次幂是 limit,那么再乘一个 i ...
分类:
其他好文 时间:
2017-07-24 22:26:24
阅读次数:
176
#include<ext/pb_ds/priority_queue.hpp>#define ll long long#define pa pair<ll,int>using namespace std;using namespace __gnu_pbds;typedef __gnu_pbds::pr ...
分类:
其他好文 时间:
2017-07-24 14:47:31
阅读次数:
167
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 163 Accepted Submission(s): 61 Problem D ...
分类:
其他好文 时间:
2017-07-23 19:47:12
阅读次数:
212
You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow an ...
分类:
其他好文 时间:
2017-07-23 14:28:14
阅读次数:
157
题目描述 给定一张地势图,所有的点都被水淹没,现在有一些关键点,要求放最少的水泵使所有关键点的水都被抽干 输入输出格式 输入格式: In the first line of the standard input there are two integers and , separated by a ...
分类:
其他好文 时间:
2017-07-22 15:31:36
阅读次数:
154
Edward has a permutation {a1, a2, … an}. He finds that if he connects each pair (ai, aj) such that i < j and ai > aj, he will get a graph. For example ...
分类:
其他好文 时间:
2017-07-22 12:14:17
阅读次数:
197
Given an unsorted array, find the largest pair sum. Solution 1. O(n*logn) runtime, using sorting Solution 2. O(n) runtime, using heapify (max priority ...
分类:
其他好文 时间:
2017-07-22 09:55:44
阅读次数:
125
A - Proud Merchants HDU - 3466(带限制的01背包) 题意: 给你m元,去买大米,每袋大米给你p,q,v 当你手中的钱 >= q时,才能买价格为p的这袋大米,它的价值是v,求最大价值。 01背包的转移方程根据题意很容易写出来,但是会有问题。 for (int i = 1; ...
分类:
其他好文 时间:
2017-07-21 01:30:57
阅读次数:
306