- 博客(37)
- 收藏
- 关注
转载 租约机制简介
背景和介绍缓存是计算机里广泛使用的一种技术,对降低读取延迟、网络流量和服务器负载都非常有效,但也带来了一致性(Consistency)的问题。所谓一致就是客户端总能读到最新的数据,使用缓存后有可能服务器端的数据已经被修改,但客户端仍然从缓存中读取陈旧的数据。为了保证一致性,有两种常见的解决办法,第一种是轮询(Polling),即每次读取数据时都先询问服务器数据是不是最新的,如果不是就从
2014-12-02 21:44:33
410
转载 LSM树由来、设计思想以及应用到HBase的索引
讲LSM树之前,需要提下三种基本的存储引擎,这样才能清楚LSM树的由来:哈希存储引擎 是哈希表的持久化实现,支持增、删、改以及随机读取操作,但不支持顺序扫描,对应的存储系统为key-value存储系统。对于key-value的插入以及查询,哈希表的复杂度都是O(1),明显比树的操作O(n)快,如果不需要有序的遍历数据,哈希表就是your Mr.RightB树存储引擎是B树(关于B树的由来
2014-11-27 21:34:21
377
转载 B树(B-Tree)的由来、数据结构、基本操作以及数据库索引的应用
B树是为磁盘存储而专门设计的一类平衡搜索树,B树的高度仅随着它所包含的节点数按对数增长,不过因为单个节点可以包含多个关键字,所以对数的底数可以比较大,实际应用中一般是50~2000,给个直观的数字,一棵分支因子为1001、高度为2(不包含根节点)的B树,可以存储超过10亿个关键字!1.从磁盘结构讲起计算机的机械磁盘,为了摊还机械移动花费的等待时间,磁盘会一次存取多个数据项而不是一个
2014-11-27 21:29:34
779
转载 缓存设计,LIRS,cache锁粒度
http://www.oschina.net/question/12_91856互联网架构中缓存无处不在,某厂牛人曾经说过:”缓存就像清凉油,哪里不舒服,抹一下就好了”。高品质的存储容量小,价格高;低品质存储容量大,价格低,缓存的目的就在于”扩充”高品质存储的容量。本文探讨缓存相关的一些问题。LRU替换算法缓存的技术点包括内存管理和替换算法。LRU是使用最多的替换算法,
2014-11-27 20:56:07
540
转载 LIRS缓存替换算法
http://www.cnblogs.com/dyllove98/archive/2013/06/08/3127492.htmlLIRS缓存替换算法LIRS (Low Inter-reference Recency Set)是一个页替换算法,相比于LRU(Least Recently Used)和很多其他的替换算法,LIRS具有较高的性能。这是通过使用两次访问同一页之间的距离(
2014-11-27 20:45:18
1177
转载 vi/vim 基本使用方法
本文介绍了vi (vim)的基本使用方法,但对于普通用户来说基本上够了!vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令。由于对Unix及Linux系统的任何版本,vi编辑器是完全相同的,因此您可以在其他任何介绍vi的地方进一步了解它。Vi也是Linux中最基本的文本编辑器,学会它后,您将在Linux
2014-10-30 10:29:13
313
转载 Eclipse快捷键大全
Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl+D: 删除当前行 Ctrl+Alt+↓ 复制当前行到下一行(复制增加)Ctrl+Alt+↑ 复制当前行到上一行(复制增加)Alt+↓ 当前行和下面一行交互位置(特别实用,可以省去先剪切,再粘贴了)Alt+↑ 当前行和上面一行交互位置(同上)Alt+← 前一个编辑的
2014-10-29 14:28:32
336
转载 程序员技术练级攻略
目录(?)[-]前言启蒙入门进阶加深高级深入月光博客6月12日发表了《写给新手程序员的一封信》,翻译自《An open letter to those who want to start programming》,我的朋友(他在本站的id是Mailper)告诉我,他希望在酷壳上看到一篇更具操作性的文章。因为他也是喜欢编程和技术的家伙,于是,我让他把他的一些学习Python和We
2014-10-04 21:08:12
387
转载 编程中无穷大常量的设定技巧
如果问题中各数据的范围明确,那么无穷大的设定不是问题,在不明确的情况下,很多程序员都取0x7fffffff作为无穷大,因为这是32-bit int的最大值。如果这个无穷大只用于一般的比较(比如求最小值时min变量的初值),那么0x7fffffff确实是一个完美的选择,但是在更多的情况下,0x7fffffff并不是一个好的选择。很多时候我们并不只是单纯拿无穷大来作比较,而是会运算后再做比
2014-10-04 20:41:37
340
原创 Codeforces Round #188 (Div. 2)
很长时间没有做了,也就很长时间没有写了,rating哗哗的往下掉啊 ,已经变绿了,这次三题挂了一个,a2Y,b1Y,A#include #include#includeusing namespace std;int main(){ long long i,j,k,n,m; cin>>n>>k; m = k*2-1; if(m>n) {
2013-06-16 23:52:50
452
原创 UVA11796Dog Distance
模版抄错了 真要命。。训练指南题 转化为相对运动 求出相对位移 假设a不动 b的相对位移 即求a到b所走线段的最短路径 依次更新#include #include#include#include#include#includeusing namespace std;struct pointt{ double x,y; pointt(doubl
2013-05-16 21:12:05
590
原创 UVA 11178 Morley's Theorem(Morley定理)
求三角形每个内角的三等分线交出来的三角形的顶点 根据求角的模版和旋转的模版 以及相交的 求。 #include #include#include#include#include#includeusing namespace std;struct pointt{ double x,y; pointt(double x=0,double y=0
2013-05-15 21:44:33
492
原创 计算几何的一些模版
struct pointt{ double x,y; pointt(double x=0,double y=0):x(x),y(y){}//构造函数 方便代码编写};typedef pointt vector;vector operator + (vector a,vector b){return vector(a.x+b.x,a.y+b.y);}vect
2013-05-15 21:30:56
527
原创 usaco2.34Money Systems
完全背包 DP就是短f[i] += f[i-c[i]];/* ID: your_id_here PROG: money LANG: C++*/#include #include#include#includeusing namespace std;long long f[10005];int c[30];int main(){ fre
2013-03-18 20:57:16
570
原创 Codeforces Round #174 (Div. 2)
A题 写麻烦了 直接乘 p-1次就可以 我还用快速幂 把1--p-1都求了出来 边求边取模#include #include#include#include#include#includeusing namespace std;int result(int a,int b,int m){ int d,t; d=1; t=a; while (b>0
2013-03-18 18:07:06
556
原创 Codeforces Round #172 (Div. 2)
意外的变蓝了,才解了两道 ,以为要掉rating呢 最近好几次CF都挂在精度上了,这次也是,B题又忘记用64位了 导致错了几次A题首字母大写#include #include#include#includeusing namespace std;char str[1010];int main(){ int i,j,k,n; cin>>str;
2013-03-15 18:28:40
503
原创 usaco2.33Zero Sum
悲催的题意 看了N久 最后还是让WL帮翻译的 原来空格的意思是多位数 比如2 3 就是23dfs 枚举所有可能的组合 再保存为0的 再排下序就OK/* ID: your_id_here PROG: zerosum LANG: C++*/#include #include#include#include#includeusing namespace st
2013-03-01 17:16:48
277
原创 usaco2.32Cow Pedigrees
对于DP很是无奈 搜了一篇报告 感觉还是不错 能懂 如下:解题思路:一棵树可以由两个子树和一个根节点构造而来,这个是解题核心(怎么就想不到呢,真是太笨了),知道这个就好推DP方程了。f[i][j]表示i个节点组成深度不超过j的二叉树的数量。两个子树的总节点数为i-1,假设左子树总节点数为m,那么右子树总节点数为i-1-m。f[m][j-1]表示为左子树深度最多为j-1层的二叉树的数量,f[i
2013-03-01 14:29:43
280
原创 Codeforces Round #170 (Div. 2)
A 顺时针 逆时针选一个最大的就好#include #include#include#include#includeusing namespace std;int d[1001];int main(){ int i,j,k,n,a,b,t; cin>>n; for(i = 1; i <= n ; i++) cin>>d[i]; c
2013-03-01 14:26:51
313
原创 usaco2.31Longest Prefix
就是枚举吧 看当前i位置是否能达到 /* ID: your_id_here PROG: prefix LANG: C++*/#include #include#include#include#includeusing namespace std;char p[210][12],ss[200010];int f[200010];int main()
2013-02-27 09:52:54
236
原创 usaco2.24Party Lamps
乱七八糟的写 改着改着就这么过了。。dfs枚举 可以看出每个串前六位跟后面的都是一样的 比较不同也就看前6位就可以了/* ID: your_id_here PROG: lamps LANG: C++*/#include #include#include#include#includeusing namespace std;int f[10],n,c,on
2013-02-25 20:29:22
255
原创 usaco2.23Runaround Numbers
题意看了N久,判断是不是什么循环数 ,符合它的规定就行,模拟/* ID: your_id_here PROG: runround LANG: C++*/#include #include#include#include#includeusing namespace std;long long n;int judge(long long x){
2013-02-25 15:47:24
291
原创 usaco2.22Subset Sums
看懂题意后 立马想到dfs 之后随手写了一个dfs TLE 看了下人家写的才知道是背包/* ID: your_id_here PROG: subset LANG: C++*/#include #include#include#include#includeusing namespace std;int s,sum,n;long long f[50][
2013-02-25 13:25:54
307
原创 usaco2.21Preface Numbering
/* ID: your_id_here PROG: preface LANG: C++*/#include #include#include#include#includeusing namespace std;int f[15]={1,4,5,9,10,40,50,90,100,400,500,900,1000},num[10];int co[15][1
2013-02-25 10:26:38
277
原创 usaco2.14Hamming Codes
Hamming CodesRob Kolstad Given N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming distance of D (1 <= D
2013-02-21 17:13:07
328
原创 usaco2.13Healthy Holsteins(dfs枚举)
Healthy HolsteinsBurch & Kolstad Farmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum daily vit
2013-02-21 14:29:18
374
原创 usaco2.12Sorting a Three-Valued Sequence
Sorting a Three-Valued Sequence IOI'96 - Day 2 Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at
2013-02-21 11:13:43
412
原创 usaco2.11The Castle
The CastleIOI'94 - Day 1 In a stroke of luck almost beyond imagination, Farmer John was sent a ticket to the Irish Sweepstakes (really a lottery) for his birthday. This ticket turned out to have o
2013-02-20 20:41:14
265
原创 poj1113Wall
http://poj.org/problem?id=1113正好是凸包的周长加一圆周 套一下各种叉积、距离的模板就OK了。要确定一个最低点作为凸包的起点 这个点一定得为凸包上的点 找最低的若有多个找最左的 然后Graham-Scan算法。按极角排下序,其实就是按某点到起点形成的向量与另一点到起点形成的向量的左右关系 很明显 叉积判。#include #include#inclu
2013-02-19 20:24:57
275
原创 Codeforces Round #167 (Div. 2)
B题和C题连着两题错在精度上,晕了,都是一个变量忘记定义成64位的A#include #include#include#include#includeusing namespace std;int p[110],nu[10];int main(){ int i,j,k,n,s=0,g=0; cin>>n; for(i = 1; i <= n ; i+
2013-02-19 08:11:22
269
原创 Codeforces Round #166 (Div. 2)
A枚举#include #include#include#includeusing namespace std;int judge(int x){ int f[20],g=0; memset(f,0,sizeof(f)); while(x) { g++; int k = x%10;
2013-02-12 19:16:38
305
原创 poj1584A Round Peg in a Ground Hole
http://poj.org/problem?id=1584恶心的精度。。非得改得跟模板一样才给过了1 判凸包 (可以共线)2 判圆心是否在多边形内3 圆心到各边的距离与r的关系#include #include#include#include#include#define eps 1e-8#define _sign(x) ((x) > eps?1:((
2013-02-12 18:45:17
359
原创 poj1408Fishnet
http://poj.org/problem?id=1408求分割出来的最大的面积 求交点坐标 枚举n*n个面积 对这题相当无语 实在不知道精度该加哪 加了精度一直WA 去掉就AC了。#include #include#include#include#include#define eps 1e-8using namespace std;typedef str
2013-02-12 15:14:57
388
原创 poj1039pipe
http://poj.org/problem?id=1039计算几何就是麻烦 这精度那精度的。。题意:有一打折的管道,从管口射入光线,求光线能传播的最长x距离。最长肯定是 一上一下的连接 枚举所有这样的连线 再判断是能穿过这个折点。能穿过:折点上下两个点在线段两侧。若不能算一下相交点在哪里,求出坐标,与maxx相比取较大值。刚才CF去了 回来补完。。#include #in
2013-02-11 23:24:03
345
原创 poj2031(最小生成树)
http://poj.org/problem?id=2031这题被分到计算几何中了,是挺简单的最小生成树,把细胞当成图中的点,各点之间的边权 = 细胞间的距离-两细胞的半径再套最小生成树的模板就OK了#include #include#include#include#include#includeusing namespace std;typedef str
2013-02-11 16:01:27
278
原创 poj1265(pick定理)
pick公式:S = 内部的点+边界的点/2-1;http://poj.org/problem?id=1265 题意不太好懂 给出的x,y不是坐标 是前一个点往下一个走的x距离和y距离 求坐标 把前面的依次加起来即可面积可以由叉积算得 边界上得点由gcd算得 根据公式算内部的点#include #include#include#includeusing namespa
2013-02-10 22:11:55
415
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅