自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

mfcheer

已搬家至:www.mfcheer.com

  • 博客(545)
  • 资源 (1)
  • 收藏
  • 关注

原创 hdu 1115 Lifting the Stone【求多边形重心】

http://acm.hdu.edu.cn/showproblem.php?pid=1115代码:#include <iostream>#include <set>#include <string>#include <cstdio>#include <string.h>#include <algorithm>#include <vector>using namespace std;dou

2015-12-02 22:24:56 334

原创 Codeforces Round #334 (Div. 2)

http://codeforces.com/contest/604A:#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>#include <bitset>#include <math.h>#include <ctype.h>#include <time.h>#include <que

2015-12-02 20:28:48 325

原创 Codeforces Round #333 (Div. 2) C. The Two Routes

题目链接:http://codeforces.com/contest/602/problem/C题意:给你一个完全图,edge是铁路或公路,火车只走铁路,汽车只公路。求使得火车汽车都从1到达n点所需的最短时间,并且两车途中不得同时到达同一点(除了n点)。解法:由于是完全图,一定有火车或汽车直接由1到n 。求另一车的最短路径即可。代码:#include <iostream>#include <cma

2015-11-28 19:58:03 442

原创 Redis内存回收:LRU算法

LRU算法(最近最久未使用算法)LRU算法作为内存管理的一种有效算法,其含义是在内存有限的情况下,当内存容量不足时,为了保证程序的运行,这时就不得不淘汰内存中的一些对象,释放这些对象占用的空间,那么选择淘汰哪些对象呢?LRU算法就提供了一种策略,告诉我们选择最近一段时间内,最久未使用的对象将其淘汰,至于为什么要选择最久未使用的,可以想想,最近一段时间内使用的东西,我们是不是可能一会又要用到呢~,而很

2015-11-23 19:01:25 535

原创 Linux虚拟地址空间分布

在多任务操作系统中,每个进程都运行在属于自己的内存沙盘中。这个沙盘就是虚拟地址空间(Virtual Address Space),在32位模式下它是一个4GB的内存地址块。在Linux系统中, 内核进程和用户进程所占的虚拟内存比例是1:3,而Windows系统为2:2(通过设置Large-Add

2015-11-20 19:31:19 778

原创 bellman_ford 模板

const int INF = 0x3f3f3f3f;const int MAXN = 550;int dis[MAXN];struct Edge{ int u, v, cost; Edge(int _u = 0, int _v = 0, int _cost = 0) :u (_u),v(_v), cost(_cost){};};vector<Edge> E;bool bell

2015-11-20 12:25:21 339

原创 Linux基本网络命令

pingping发送ECHO_REQUEST包到你指定的地址。这样你可以很方便确认你的电脑和Internet或是一个指定的IP地址是不是通的。使用 -c 开关,可以指定发送ECHO_REQUEST包的个数。whoiswhois命令输出指定站点的whois记录,可以查看到更多如谁注册和持有这个站点这样的信息。ifconfigifconfig用于输出网络接口配置、调优和debug的各种选项。可以快捷地查

2015-11-18 22:10:31 387

原创 Rabin数字签名 Lamport 一次签名

代码:#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>#include<iostream>#include<string.h>#include<math.h>#include<algorithm>#include<random>using namespace std;const int S =

2015-11-08 19:36:10 2364

原创 C++primer 17.2 bitset类型

bitset类型使得位运算更为容易,定义在头文件bitset中定义和初始化bitset定义bitset时需声明包含多少位: bitset<32> bits(1u);//定义一个32位第一位为1 其他位为0 的bitsetbitset初始化的方法: bitset<n> b; n位均为0 bitset<n> b(u); 对u的低n位拷贝 bitset<n> b(s, po

2015-11-01 20:56:35 122

原创 C++primer 17.4 随机数

c语言的库函数 rand 生成的随机数为为随机数。 c++提供随机数引擎类和随机数分布类、 头文件: random随机数引擎:随机数引擎的例子:default_random_engine e;for (int i = 1;i <= 10;i++) cout << e() << endl;//e()对象生成下一个随机数随机数引擎操作 default_random_engine e;

2015-11-01 19:13:57 760

原创 机器学习

记录一些资料及学习笔记。斯坦福大学公开课 :机器学习课程 网易:http://open.163.com/special/opencourse/machinelearning.html 斯坦福机器学习课程主页:http://cs229.stanford.edu/materials.html

2015-11-01 12:59:21 399

原创 为什么构造函数不能为虚函数(转)

1从存储空间角度 虚函数对应一个vtable,这大家都知道,可是这个vtable其实是存储在对象的内存空间的。问题出来了,如果构造函数是虚的,就需要通过 vtable来调用,可是对象还没有实例化,也就是内存空间还没有,无法找到vtable,所以构造函数不能是虚函数。2从实现上看,vbtl在构造函数调用后才建立,因而构造函数不可能成为虚函数 从实际含义上看,在调用构造函数时还不能确定对象的真实类型

2015-10-31 16:08:26 366

原创 LightOJ 1433 - Minimum Arc Distance

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1433题意:给你圆心坐标及圆上的两点坐标,求两点距离。 求对应的圆心角度再求距离。水~代码:#include <iostream>#include <stdio.h>#include <cmath>#include <string>#include <string.h>u

2015-10-29 21:03:34 467

原创 Java-单例设计模式(基础)

设计模式对问题的行之有效的解决方法,其实它是一种思想。不要固化。1,单例设计模式。解决的问题:保证一个类在内存中的对象唯一性。必须对于多个程序使用同一配置信息对象时,就该保证对象唯一性。 如何保证对象唯一性? 1),不可以让其他程序用new创建对象。 2),在该类中,创建一个本类实例。 3),对外提供方法让其他程序获取该对象。 步骤: 1),私有化该类构造函数

2015-10-29 16:44:22 443

原创 Java编程思想 - 第7章、复用类

代码的复用has a: 组合is a: 继承中庸之道:代理1,组合,继承,代理为了继承,一般的规则是将所有的数据成员都设置为private,而将所有的方法都设置为public。这样,当不同的包下的类继承该类时,就可以获得该类所有的方法,和包内、包外没有区别。如果不加修饰符,就是限制包内访问,那么包外继承的时候,只能获得public修饰的方法,这样内外的方法不一致,就会出现问题了。当然,特殊情况需

2015-10-29 13:03:03 515

原创 Java - 继承(基础)

继承:增强代码复用性,使类和类之间产生关系,为多肽提供前提。 extends 关键字 使用类的继承时,查看体系顶层类,了解功能,创建子类对象完善功能的使用。什么时候用继承?类与类之间存在所属关系,定义继承。比如xx(狗)是yy(犬科动物)的一种。java支持单继承,对c++多继承进行改良,支持多重继承。单继承 :一个子类只能有一个父类。class C extends A{}多继承 :一个子类

2015-10-28 21:00:18 504

原创 Merkle-Hellman背包密码算法

代码:#include <stdio.h>#include <iostream>#include <string.h>#include <cmath>#include <string>#include <set>#include <map>#include <vector>#include <time.h>long long gcd(long long a, long long b)

2015-10-27 01:00:36 3703

原创 poj 2987 Firing【最大闭合子图】

题目链接:http://poj.org/problem?id=2987最闭合子图资料:http://blog.sina.com.cn/s/blog_48f85e1d0100mxem.html代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <qu

2015-10-13 20:27:18 375

原创 hdu 2686 Matrix【费用流】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686代码:#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#i

2015-10-13 15:13:32 432

原创 hdu 2686 Matrix【多线程DP】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2686代码:#include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>#include<queue>using namespace std;int n;int a[50][50];int dp[35][35

2015-10-11 10:35:52 470

原创 hdu 1565 方格取数(1)【最大流】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1565代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <sstream>#include <stdio.h>#

2015-10-10 19:53:46 383

原创 LightOJ 1082 - Array Queries【线段树最值】

题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1082一水~代码:#include <stdio.h>#include <iostream>#include <string>#include <cstring>#include <cmath>#include <cstdlib>#include <algorith

2015-10-10 18:28:45 457

原创 LightOJ 1017 - Brush (III)【一般DP】

题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017题意: 给你一把刷子,每次最多刷w宽的区域,给你n个点的间距,最多刷k次,问你最多能刷到几个点。解法: 按坐标排序。 dp[i][j] 表示刷到i用j次最优解,用num[i]记录i位置最多能刷多少个。代码:#include <stdio.h>#include <mat

2015-10-10 03:02:07 371

原创 poj 3280 Cheapest Palindrome【区间DP】

题目链接:http://poj.org/problem?id=3280题意: 给你一个字符串以及添加和删除每个字符的代价,求使得原串变为回文串的最小的代价。解法: dp[i][j]表示使得i到j变为回文的最小代价。 dp[i][j] = min(dp[i+1][j]+add[i],dp[i+1][j]+del[i],dp[i][j-1]+add[j],dp[i][j-1]+del[j]) 如

2015-10-09 17:57:09 294

原创 BZOJ 1050: [HAOI2006]旅行comf

题目链接:1050: [HAOI2006]旅行comf求起点到终点的一条路径,使得路径最长边与最短边比值最小。 边按小到大排序。枚举最小边值依次加边,直至起点终点联通,更新答案。代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>

2015-10-08 19:26:57 88

原创 BZOJ 1207: [HNOI2004]打鼹鼠

题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1207动态规划 当前的每步必是由之前的某一步得来的代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <s

2015-10-08 09:21:53 413

原创 ZOJ 3203 3203 Light Bulb【三分法】

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3366二分法用来解决单调问题,三分法解决凸(凹)函数问题,逼近求解代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include

2015-10-08 00:50:16 365

原创 BZOJ [BeiJing2006]狼抓兔子 【网络流】

题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1001就是求最小割 阻止两个兔子窝间联通代码:#include <iostream>#include <algorithm>#include <set>#include <map>#include <string.h>#include <queue>#include <sstrea

2015-10-07 23:46:34 388

原创 hdu 3605 Escape【二分图多重匹配】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3605多重匹配代码:#include <iostream> #include <algorithm> #include <set> #include <map> #include <string.h> #include <queue> #include <sstream> #i

2015-10-06 19:07:06 329

原创 51nod 1090 3个数和为0

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1090水题。 枚举前两项 二分第三项。代码:#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>#include <math.h>#include <st

2015-10-04 19:49:09 331

原创 51nod 1135 原根

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1135代码:#include <cstdio>#include <cstring>#include <queue>#include <iostream>#include <math.h>using namespace std;const int MAXN =

2015-10-03 02:06:11 418

原创 51nod 1181 质数中的质数(质数筛法)

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1181代码:#include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <math.h> #include <stack>

2015-10-03 02:04:04 403

原创 51nod 1212 无向图最小生成树

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1212水题。代码:#include <stdio.h> #include <iostream> #include <string.h> #include <algorithm> #include <math.h> #include <stack>

2015-10-03 01:52:24 331

原创 51nod 1242 斐波那契数列的第N项【矩阵快速幂】

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1242代码:#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>#include <math.h>#include <ctype.h>#include <

2015-10-03 01:36:57 368

原创 51nod 1256 乘法逆元

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1256水题求逆元。。代码:#include <stdio.h>#include <iostream>#include <string.h>#include <string>#include <cstring>#include <cmath>#includ

2015-10-03 01:31:26 357

原创 poj 2104 K-th Number【主席树】

题目链接:http://poj.org/problem?id=2104询问求区间第k大。代码:#include <stdio.h>#include <iostream>#include <string.h>#include <string>#include <cstring>#include <cmath>#include <cstdlib>#include <algorithm>#

2015-10-03 00:56:52 327

原创 51nod 1174 区间中最大的数【线段树】

题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1174好久没写线段树了,区间最大值,水题。。代码:#include <stdio.h> #include <iostream> #include <string> #include <cstring> #include <cmath> #incl

2015-10-02 19:52:35 387

原创 hdu 5492 Find a path【dp】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5492原来公式(n+m-1)* ∑(ai - ai_ave)^2,求公式的最小值,即最小方差路径。 公式展开化简后可以得到 (n+m-1)*s1-s2 s1为ai平方和,s2为和的平方。 dp[i][j][k] 表示 到达i行,j列时,ai的和为k时的最小平方和。代码:#include <ios

2015-09-29 19:08:54 91

原创 ACdream 1099 瑶瑶的第K大

题目链接:点击打开链接题意:求数组第k大的元素,直接排序会超时的,get到 nth_element 这个函数nth_element 用法:nth_element(start, start+n, end)使第n大元素处于第n位置(从0开始,其位置是下标为n的元素),并且比这个元素小的元素都排在这个元素之前,比这个元素大的元素都排在这个元素之后,但不能保证他们是有序的,原理类似快速

2015-09-28 20:25:12 423

原创 hdu 1950 Bridging signals【LIS nlogn】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1950题意:LIS nlogn算法代码:#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <cmath>#include <queue>#include <vector>#inc

2015-09-28 19:55:18 409

g++编译器for c++

g++编译器 c++ this is a program for C++

2014-10-24

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除