自定义博客皮肤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

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

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

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

2015-10-31 16:08:26 356

原创 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 449

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

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

2015-10-29 16:44:22 428

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

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

2015-10-29 13:03:03 499

原创 Java - 继承(基础)

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

2015-10-28 21:00:18 474

原创 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 3637

原创 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 362

原创 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 413

原创 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 458

原创 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 376

原创 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 438

原创 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 358

原创 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 277

原创 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 73

原创 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 404

原创 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 354

原创 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 376

原创 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 318

原创 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 316

原创 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 387

原创 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 383

原创 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 321

原创 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 355

原创 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 346

原创 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 318

原创 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 375

g++编译器for c++

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

2014-10-24

空空如也

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

TA关注的人

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