自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Or_me

♑_FAR AWAY

  • 博客(111)
  • 资源 (2)
  • 收藏
  • 关注

原创 第3章 对于所有对象都通用的方法

第7条:在改写equals的时候请准守通用约定第8条:改写equals时总是要改写hashCode第9条:总是要改写toString第10条:谨慎地改写clone第11条:考虑实现Comparable接口

2022-05-30 19:55:36 170 1

翻译 lower_bound()与upper_bound()

所在头文件:#include<algorithm>函数分类:Binary search (operating on partitioned/sorted ranges)函数功能:lower_bound()返回一个迭代器指针,指向val出现在这个被查找序列中出现的第一个位置;upper_bound()返回一个迭代器指针,指向val出现在这个被查找序列中出现的最后一个位置的后一个位置。lower_bou

2016-05-06 11:21:36 1073

原创 蘑菇街春招 - 编程题第二题 - 隐式图搜索 - 四个水杯

#include <bits/stdc++.h>using namespace std;struct CUP{ int x, y;};struct Node{ CUP a[4]; int step;} st, ENDDD;bool flag[111][111][111][111];int dir[12][2] = { 0, 1, 0, 2,

2016-03-31 21:41:59 1166

原创 UVALive 5009

Link:click here The question:给出n组a,b,c的值,求出函数值最大值的最小值 Solution:三分,黄金分割法(优选法),Fibonacci搜索都可求单峰函数的极值。 Conclusion:跟据题目要求判断循环的次数或者需要控制的精度

2016-03-22 19:42:41 667

原创 HDU 5128

Link:click here The question:在平面上给出n(4 <= n <= 30)个点,从中选出8个点够成两个矩形,使得矩形的面积最大,如果不存在,输出”imp”。

2016-03-22 18:55:22 467

原创 UVA 10341

Link:click here The question:给出6个整数,求方程f(x)等于0的时候的解。 Solution:由0 <= x <= 1可知f(x)单调递减,二分。 Conclusion:数值计算的公式要写成宏定义的形式

2016-03-21 18:45:38 374

原创 UVALive 4127

Link:click here The question:给出n座山的高和宽,山视为等腰三角形,从上往下看,求山的轮廓的长度,山之间的空白不算。 Solution:用竖线在山与山的交点和顶点处,把所有山分成一段一段的的线段,统计竖线内每段线段的长度,累加即可。先把所有端点的横坐标放入数组X里, 然后对线段两两求交,把交点的横坐标也放入数组X里,然后排序去重。求出每条线段与竖线的交点的y坐标的

2016-03-21 18:42:31 337

原创 POJ 1845

Link:click here The question:求A的B次方的所有因子的和模9901的值

2016-03-20 21:19:49 309

原创 Largest palindrome product

Link:click here The question:求两个三位乘积得到的最大的回文数 Solution:暴力枚举999到100,维护最大值 Conclusion:第一次做的时候没有维护最大值,遇到第一个出现的回文数就结束了,得到的是580085 = 995 * 583; 但结果并不对,580085是第一个出现的,它不是最大的,维护了最大值后得到906609 = 993 * 913,

2016-03-20 21:04:01 524

原创 二叉树学习(二)

二叉树值得思考的一些问题!!1. 求二叉树的高度设二叉树的高度函数为f(xx),则: f(x)={0,Max{f(x−>lchild),f(x−>rchild)}+1,if x = NULLothersf(x) =\begin{cases}0, & \text{if $x$ = NULL} \\Max\{f(x->lchild), f(x->rchild)\} + 1, & \text{

2016-01-22 16:20:18 775

原创 二叉树学习(一)

树的基础知识 树的定义: 树包含n(n ≥\ge 0 )个节点,n = 0时称为空树。 在树的结构关系中,有且仅有一个节点没有前趋节点,这个节点称为树的根节点。 除根节点外,树中其他的节点有且仅有一个前趋节点,但可以有很多后继节点。如图,A为根节点。 树的基本术语: 结点的度:每个节点具有的子树的个数(后继节点的个数)称为该节点的度;A的度为3,B

2016-01-21 09:57:41 2436

原创 LeecCode 17

Link:click here 题意:给出手机键盘上的按键数字,求出所有可能得到的字母组合 思路:用两个vector不断模拟。 Code:#include <bits/stdc++.h>using namespace std;vector<string> letterCombinations(string digits){ string str[] = {"abc", "def"

2016-01-16 20:25:38 517

原创 二分幂、快速幂、矩阵快速幂、幂取模

二分幂:如计算a^n;如果n为偶数,则计算a^n/2(递归到n=0),再计算(a^n/2)(a^n/2),就可得出结果;如果n为奇数,则先计算a^(n-1)/2(递归到n=0),再计算(a^(n-1)/2)*(a^(n-1)/2)a,就可得出结果。long long fun(int a,int b){ if (b==0) return 1; if (b==1)

2015-11-09 13:42:42 1902

原创 HDU 1394 线段树求逆序数 + 递推逆序数

template <class T>inline bool rd(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != '-' && (c < '0' || c > '9')) c = getchar(); sgn = (c == '-') ? -1 : 1;

2015-11-04 09:17:10 581

原创 后缀数组模板

#include <set>#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define maxn 1100000using namespace std;const int MAXN = 500;char s[MAXN];int sa[MAXN];

2015-10-01 19:43:38 457

原创 名次树 - 模板

UvaLive 5031#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <cstdlib>using namespace std;const int maxnode = 20005;const int maxw = 60005;const int maxc = 50

2015-09-19 10:46:57 719

原创 最短路 - Dijkstra()

http://acm.nyist.net/JudgeOnline/problem.php?pid=115#include <stdio.h>#include <string.h>#include <iostream>#include <stdlib.h>#define inf 0x3f3f3f3f#define N 1005using namespace std;int d[N], G

2015-09-18 17:31:37 459

原创 最小生成树 - Kruskal()

//http://acm.hdu.edu.cn/showproblem.php?pid=1233#include <cstdio>#include <algorithm>using namespace std;const int N = 105;int father[N];int find(int x){ if (x != father[x]) father[x

2015-09-10 15:03:08 447

原创 最小生成树 - Prime()

//http://acm.hdu.edu.cn/showproblem.php?pid=1102#include <bits/stdc++.h>#define N 111using namespace std;int n;int G[N][N];int vis[N], lowcost[N];int prime()//只与点有关O(n * n),适合稠密图{ int sum =

2015-09-10 08:49:21 567

原创 hash + bsgs模板

//POJ 2417//baby_step giant_step// a^x = b (mod n) n为素数,a,b < n// 求解上式 0 <= x < n的解#include <cmath>#include <cstdio>#include <cstring>#define MOD 76543using namespace std;int hs[MOD], head[MOD

2015-08-17 11:02:12 831

原创 线性筛素数

void Init()//线性筛素数{ for (int i = 2; i < N; i++) { if (mpf[i] == 0) mpf[i] = prime[pn++] = i; for (int j = 0; j < pn; j++) { if (i * prime[j] > N

2015-08-16 16:46:25 441

原创 HDU-2647-邻接表模板

#include<iostream>#include<cstring>#include<queue>#include<cstdio>using namespace std;#define MAX 10005int n, sum, ans;int into[MAX], head[MAX], money[MAX];struct Reward{ int to; int n

2015-08-11 22:28:17 587

原创 组合数模板+ 卢卡斯定理

Template one:#include <stdio.h>#include <stdlib.h>long long Combination(int n,int m){ long long nr = 1; for (int j = 0; j < m; j++) { nr *= (n - j); nr/=(j+1); }

2015-08-01 11:38:37 782

原创 Template of ACoCorasickAutomata

LA 4670#include <cstring>#include <cstdio>#include <vector>using namespace std;struct Node{ struct Node *fail; struct Node *next[26]; int tot; int id; Node() { fai

2015-07-18 10:26:01 369

原创 计算几何模板 - 全

#include <cmath>#include <cstdio>#include <iostream>using namespace std;struct Point{ double x,y; Point(double x=0.0,double y=0.0):x(x),y(y) {}//构造函数,方便函数编写};typedef Point Vector;//Vecto

2015-04-25 06:50:35 656

原创 并查集

在一些有N个元素的几何应用问题中,通常是在开始时让每个元素构成一个单元素的集合,然后按一定顺序将属于同一组的元素所在的几何合并,其间反复查找一个元素在哪个集合中。这类题目看似并不复杂,但数据量极大,若用正常的数据结构来描述的话,往往在空间上消耗过大,即使在空间上勉强通过,时间复杂度也是极高的,所以这类问题应该用并查集类解决。 并查集类似一个森林,每个节点均有一个fater[x]来表示他的父

2015-04-18 10:47:50 412

原创 堆(heap)

堆是一个完全二叉树(除最后一层外,每一层上的节点数均达到最大值,在最后一层上只缺少右边的几个节点),用一个一位数组来实现。堆中存储的数是局部有序的。堆分为最大堆和最小堆:对于最大堆,任意一个节点的值都大于或等于其任意一个子节点的值,所以根节点一定是堆中的最大值;对于最小堆,任意一个节点的值都小于或等于其任意一个字节的值,所以根节点一定是堆中的最小值。这和优先队列一样,都是将优先级最高的放在队首。堆

2015-04-17 08:18:28 659

原创 LeetCoder第一题

题目:http://oj.leetcode.com/problems/two-sum/

2015-04-14 10:51:03 822

原创 Value Of Type

value fo type

2015-03-30 21:30:41 547

原创 Template of KMP

Template of KMP#include <stdio.h>#include <string.h>int count = 0;char s[10005], l[1000005];void getnext(char *src, int m, int *next){ int i = 0,j = -1; next[0] = j; while(i < m) {

2015-03-16 20:16:14 445

原创 HDU 1010

这个题教会我DFS不要写成for循环的形式#include #include #include #include #include using namespace std;const int MAX = 10;int m, n, t, sx, sy, flag, vis[MAX][MAX];int dx[] = {1, -1, 0, 0};int dy[] = {0,

2015-01-19 16:37:25 540

原创 POJ 2312(BFS+优先队列)

#include #include #include #include #include using namespace std;const int MAX = 350;int m, n, sx, sy, ex, ey, ans, map[MAX][MAX], vis[MAX][MAX];int dir[8] = {1, 0, -1, 0, 0, 1, 0, -1};struct

2015-01-19 11:57:35 611

原创 线段树

线段树(1):点修改#include const int MAXN = 50005;int sum[MAXN << 2];void pushup(int rt){ sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];}void build(int L, int R, int rt){ if (L == R) { scanf("%d", &

2015-01-17 16:41:41 634

原创 挑战编程-第六章-组合数学-总结

挑战编程-第六章-组合数学-总结    学习用java处理大数很有必要,解组合数学的题就是一个找公式推规律的过程。推公式的过程又类似于推导状态转移方程,再推出公式后,往往会发现题目的数据是超long long的,再用大数方法来处理,代码很随意就能上200行,但是如果用java来写的话,推出公式,组合数学的题就是水题。代码都是别人家的。Uva 10183:    Meanin

2015-01-16 19:30:49 1273

原创 ubuntu 14.04 LTS Desktop 搭建LAMP环境

ubuntu 14.04 LTS Desktop 搭建LAMP环境1、sudo apt-get install apache2 #安装apache2    安装完成后,通过 apache2 -v 查看是否安装成功    然后可通过浏览器来访问服务器的IP。    将会出现 It works!    apache2已经正常运行。2、sudo apt-get insta

2015-01-03 14:45:13 810

原创 Linux学习小结(二)

ubuntu 14.04 LTS安装中文输入法:sudo apt-get install updatesudo apt-get install fcitx-table-wbpy配置完成后重启。编译安装一个开源软件的步骤是固定的:1、./configure2、make3、sudo make install首先解压压缩包,然后进入源码目录,再执行上面的三个步骤,完成

2014-12-17 11:07:08 623

原创 图形手势识别

图形手势识别http://www.imooc.com/learn/131http://fattyboy.cn/gt一、手势识别的常见算法:1、网格识别(马赛克识别)把用户绘制的图形和图形库里的图形放到同一张网格里面,然后逐个格子的去比较他们的相似度。核心思想类似于马赛克识别,例如比较两张照片是否相像的时候,先把两张照片马赛克化,然后去比较方块是否相像。2、方向识别

2014-12-12 16:50:08 2963

原创 输入模板

long long Scan(){ long long res = 0 , ch; while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) ) { if( ch == EOF ) return 1 << 30 ; } res = ch - '0' ; while(

2014-12-06 11:37:13 674

原创 fibnacci数列模板

#include #include using namespace std;const int MAX=10;#define __int64 long long#define Bit(n) 1<<n#define CLR(arr,val) memset(arr,val,sizeof(arr))class Matrix{public: Matrix(int r,int c)

2014-12-03 17:55:02 540

原创 C++获取当前时间和计算程序运行时间的方法

获取当前时间:#include #include using namespace std;int main(){ SYSTEMTIME sys; GetLocalTime(&sys); cout<<sys.wYear<<"年"; cout<<sys.wMonth<<"月"; cout<<sys.wDay<<"日"; cout<<sys.w

2014-10-24 19:43:16 6655

具体数学英文版

其实是因为自己看不懂才上传来的,希望不小心被哪位喜欢数学而又精通英语的喜欢帮助别人的大神看见了,加以翻译!!

2014-03-19

ACM程序设计竞赛基础教程_俞经善等编

算法学习经典,虽然简短。 欢迎大家一起学习讨论!!

2014-03-19

空空如也

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

TA关注的人

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