自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(37)
  • 资源 (1)
  • 收藏
  • 关注

原创 poj 1195 二维线段树(模板题)

二维线段树模板题:#include#include#include#include#includeusing namespace std;const int maxx=1050;struct node{ int l,r; int sum;};struct node1{ int l,r; node t[maxx<<2];}q[max

2017-11-22 19:45:14 455

转载 POJ 2155 Matrix (二维线段树)

二位线段树,不好理解,多背,多理解。#include#include#include#include#includeusing namespace std;const int maxn=1010;struct nodey{ int l,r; int val;};int n;int locx[maxn],locy[maxn];struct nodex

2017-11-20 20:10:16 221

转载 hdu 5120 Intersection(求相交圆的面积)

两个相同的环重合部分的面积就是A大圆和B大圆相交的面积,减去A大圆和B小圆,减去A小圆和B大圆的面积,再加上两个小圆相交的面积,直接套,两圆相交的面积模板S = A大B大 - A大B小 - A小B大 + A小B小。#include #include #include #include #include using namespace std;const double P

2017-11-06 20:42:00 272

转载 HDU - 5536

题意:有一个数组a[], 包含n个数,从n个数中找到三个数使得 (a[i]+a[j])⊕a[k]最大,i,j,k不同;求异或的结果最大所以我们可以用01字典树,先把所有的数加入字典树中,从n个数中选出两个数a[i]和a[j],先把他们从字典树中删除,然后找到与a[i]+a[j]异或最大的数,和结果取最大值即可;最后不要忘记再把a[i]和a[j]添加到字典树中即可;#include

2017-11-04 16:30:23 232

原创 树链剖分+线段树 POJ3237 权值在边 模板

#include#include#include#include#include#include#include#include#includeusing namespace std;const int maxn=100010;struct Edge{ int to; int next;}edge[maxn*2];int head[maxn],tot;

2017-10-13 20:18:58 196

原创 树链剖分+线段树 HDU3966 权值在点 模板

树链剖分模板题。#include#include#include#include#include#includeusing namespace std;#define maxn 50010int n,m,Q;int tim;//时间戳int a[maxn];//树上每个节点的初始值int siz[maxn];//siz[u]表示以u为根的子树的节点数int top[ma

2017-10-09 20:35:23 199

原创 HDU 5050 二进制大数GCD

两个二进制数的最大公约数,模板代码如下#include#include#include#include#includeusing namespace std;#define maxn 1010struct node{ int l; int v[maxn];};bool issmaller(node x1,node x2){ if(x1.l<x2

2017-09-16 11:39:41 492

转载 错排公式

递推的推导错排公式编辑当n个编号元素放在n个编号位置,元素编号与位置编号各不对应的方法数用D(n)表示,那么D(n-1)就表示n-1个编号元素放在n-1个编号位置,各不对应的方法数,其它类推.第一步,把第n个元素放在一个位置,比如位置k,一共有n-1种方法;第二步,放编号为k的元素,这时有两种情况:⑴把它放到位置n,那么,对于剩下的n-1个元素,由于第k个元素放到了位置n,剩下n-2个

2017-09-12 20:29:26 168

转载 动态规划——最长上升子序列

nlogn算法假设存在一个序列d[1..9] = 2 1 5 3 6 4 8 9 7,可以看出来它的LIS长度为5。n下面一步一步试着找出它。我们定义一个序列B,然后令 i = 1 to 9 逐个考察这个序列。此外,我们用一个变量Len来记录现在最长算到多少了首先,把d[1]有序地放到B里,令B[1] = 2,就是说当只有1一个数字2的时候,长度为1的LIS的最

2017-09-10 16:45:54 254

原创 POJ 2449 Remmarguts' Date K短路

K短路:dijkstra+A*(rec).k短路问题模板.#include#include#include#include#include#includeusing namespace std;const int maxn=100010;int n,m,l;int dis[maxn];bool vis[maxn];int head1[maxn];int cnt[ma

2017-08-25 15:35:20 178

原创 HDU - 2896 病毒侵袭 AC自动机

题意:给出n个病毒和m个网站,找出每一个网站中含有的病毒种类,并按病毒编号升序输出,最后统计含有病毒的网站个数。AC自动机基础题,需要在构建树时多加一个标记,这题很容易超时和超内存,试啦好几遍才AC。#include#include#include#include#includeusing namespace std;struct node{ int num; int k;

2017-08-18 11:44:57 179

原创 HDU-2222 Keywords Search AC自动机模板题

给你N个单词,给你一篇文章,问给出的单词在文章中出现的次数。AC自动机基础题。模板题。#include#include#include#include#includeusing namespace std;#define N 500010int head,tail;char s[1000010],ss[100];struct node{ node *fail;

2017-08-17 11:02:16 228

原创 HDU - 1305 Immediate Decodability 字典树

字典树:问是否在给出的二进制中能找到前缀码。#include#include#include#include#includeusing namespace std;struct node{ int x; node *next[22]; node() { x=0; for(int i=0;i<2;i++) next[i]=NULL; }};node root

2017-08-16 14:08:55 177

原创 HDU - 1251 字典树

字典树模板题G++ Memory Limit ExceededC++ Accepted#include#include#include#include#includeusing namespace std;struct node{ int num; node *next[26]; node() { num=0; for(int i=0;i<26;i++)

2017-08-16 10:40:09 183

原创 hdu-1358 kmp,next数组的应用

一个长度为 n 的字符串,求该字符串的循环前缀的长度,和循环次数#include#includeint n;int next[1200000];char s[1200000];void getnext(){ int i,j; i=0; j=-1; next[0]=-1; while(i<n) { if(j==-1||s[i]==s[j]) { next[++i

2017-08-15 11:20:27 200

转载 HDU - 1255

题意:有T组测试数据,每组数据先给一个数字N,接下来的N行里,每行四个浮点数表示矩形的左上角坐标和右下角坐标,要求这些矩形至少覆盖过两次的面积。AC模板:#include#include#include#include#include#include #include#include#include#include#include#include#include#

2017-08-11 09:48:50 238

转载 HDU - 1542

题意 :给出n个矩形的左下角和右上角的坐标,求矩形面积的并代码1:点击打开链接#include #include #include #include using namespace std;const int SIZE=505;int add[SIZE<<2]; //add为区间标记,与懒惰标记类似double x[

2017-08-09 15:54:58 193

原创 hdu1698 Just a Hook 线段树区间更新,模板题

给你T组数据,N个数(初始时每个数的值为1),M个操作,每个操作把区间[a,b]里的数更新为c,问最后这N个数的和是多少。#include#include#include#include#includeusing namespace std;struct node{ int l,r,w,lazy;}a[100000*4];void up(int i){ a[i].w=a[

2017-07-25 21:06:02 219

原创 poj 3468 线段树区间更新,模板题

线段树区间更新模板题,Q是区间查询,求和。C是成段更新。#include#include#include#include#includeusing namespace std;__int64 a[100100];struct node{ __int64 l,r,w,lazy;}q[4*100100];void up(int i){ q[i].w=q[i*2].w+q[i

2017-07-25 21:03:20 209

原创 hdu1542线段树+离散化+扫描线详代码

#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<iomanip>using namespace std;const int MAXN=2000;in

2017-05-12 21:49:36 269

转载 51Nod 1091 线段的重叠

分析: 这道题对初学者看似很复杂,其实认真分析就会发现很简单。。 (下面结合例子分析一下)(本人非常弱,大神莫见笑) 首先: 先将输入的区间起点按升序排序,若起点相同则按终点降序排序 比如5组区间:(1 5)(2 4)(2 8)(3 7)(7 9) 按上面所述排序: (1 5) (2 8) (2 4) (3 7) (7 9) 这样很直观,为什么要起点升序,起点相同则按终点降序排序 起

2017-05-07 20:23:57 154

原创 线段树区间更新&&HDU1698模板

#include#include#include#include#include#include#include#includeusing namespace std;struct node{ int l; int r; int sum; int mark;}q[500000];void pushup(int i){ q[i].sum=q[i*2].sum+q[i*2+1].sum; return

2017-05-06 20:09:11 192

原创 HDU 4027

flag标记,区间更新。#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<iostream>#include<algorithm>#include<queue>#include<map>#define ll long longusing namespace std;ll n,

2017-05-03 21:45:13 156

原创 AC自动机模板 hdu2222

题目大意: 给你很多个单词,然后给你一篇文章,问给出的单词在文章中出现的次数。#include<iostream>#include<cstdio>#include<cstring>#include<string>using namespace std;#define N 500010char str[1000010], keyword[51];int head, tail;struc

2017-04-26 20:07:46 154

原创 树状数组模板

树状数组

2017-04-20 19:10:50 201

原创 Tire树模板

#include<cstdio>#include<string.h>#include<iostream>using namespace std;struct node{ int sum; node *next[26];}root;void insert(char *s){ node *p=&root,*q; int i,j,l; l=strlen

2017-04-16 21:38:00 213

原创 二叉树:已知先序和中序求后序,已知中序和后序求先序

树的三种遍历方式的遍历顺序: 先序遍历:根、左子树、右子树(特点:第一个元素为根) 中序遍历:左子树、根、右子树(特点:根的两边分别为左子树和右子树) 后序遍历:左子树、右子树、根(特点:最后一个元素为根) 有如下图的二叉树: 其先序、中序、后序遍历分别为:DBACEGF、ABCDEFG、ACBFGED。 1、已知先序和中序求后序 先序遍历的第一个字符为根,因此只需在中序遍历中找到它,

2017-04-15 17:14:38 19450 9

原创 qsort三种排序方法

qsort分别对数字,字符,字符串排序。char s1[3][10];char s2[10];int s3[5];int cmp1(const void*a,const void*b)//数字从小到大排序 { return *(int*)a-*(int*)b;}int cmp2(const void*a,const void*b)//字符按字典序排序 { return *

2017-04-08 20:04:54 996

原创 RMQ算法

RMQ算法,是一个快速求区间最值的离线算法,预处理时间复杂度O(n*log(n)),查询O(1),所以是一个很快速的算法,当然这个问题用线段树同样能够解决。问题:给出n个数ai,让你快速查询某个区间的的最值。算法分类:DP+位运算算法分析:这个算法就是基于DP和位运算符,我们用dp【i】【j】表示从第 i 位开始,到第 i + 2^j -1 位的最大值或者最小值。 那么我求dp【i】【j】的时候可

2017-03-31 21:06:15 163

原创 归并排序算法

归并排序(MERGE-SORT)是建立在归并操作上的一种有效的排序算法,该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。将已有序的子序列合并,得到完全有序的序列;即先使每个子序列有序,再使子序列段间有序。若将两个有序表合并成一个有序表,称为二路归并。 归并过程为:比较a[i]和a[j]的大小,若a[i]≤a[j],则将第一个有序表中的元素a[i]复制到r[k]中,并

2017-03-31 19:52:00 237 1

原创 快速乘取模

快速乘取模模板:#include<stdio.h>long long a,b,c;long long f(){ long long k=0; a=a%c; b=b%c; while(b>0) { if(b&1) k=(k+a)%c; a=(a+a)%c; b>>=1; } r

2017-03-29 19:18:41 397

原创 快速幂取模 。

快速幂取模模板:#include<stdio.h> long long f(long long a,long long b,long long c){ long k=1; a=a%c; while(b) { if(b&1) k=(k*a)%c; a=(a*a)%c; b>>=1; }

2017-03-29 19:15:29 225

原创 大数相乘

大数相乘,开三个数组,分别存两个大数和结果。#include<stdio.h>#include<string.h>#define N 100000char a[N];char b[N];int c[N+100];int main(){ int i,j,k,n,l1,l2,m; scanf("%d",&n); getchar(); while(n--)

2017-03-27 21:45:09 160

转载 表达式计算模板

#include<iostream> #include<cstring> #include<stack> #include<algorithm> #include<cmath> using namespace std; stack<char> s1,s2; stack<int> s3; char ch[150]={0};//用来存表达式

2017-03-26 22:08:39 250

转载 manacher算法

manacher算法核心代码: 算法基本要点:首先用一个非常巧妙的方式,将所有可能的奇数/偶数长度的回文子串都转换成了奇数长度:在每个字符的两边都插入一个特殊的符号。比如 abba 变成 #a#b#b#a#, aba变成 #a#b#a#。 为了进一步减少编码的复杂度,可以在字符串的开始加入另一个特殊字符,这样就不用特殊处理越界问题,比如$#a#b#a#。S[] = “$#1#2#2#1#

2017-03-25 21:14:24 157

原创 kmp模板

next,kmpvoid getnext(){ int i,j; i=0; j=-1; next[0]=-1; while(i<l) { if(j==-1||a[i]==a[j]) { i++; j++; next[i]=j; }

2017-03-25 11:34:43 150

原创 文章标题

扩展欧几里德    欧几里德算法:gcd(a, b)表示a, b 的最大公约数。gcd(a,b)=gcd(b,a%b)。     扩展欧几里德算法:gcd(a, b)表示a, b 的最大公约数。那么存在整数x, y使得 gcd(a, b) = a * x + b * y;不妨设a > b。     ① ,当b = 0 时,gcd(a, b) = a , 此时 x = 1, y = 0;

2017-03-24 20:40:25 166

航空订票系统

(1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括姓名、订票量、舱位等级1,2或3)以及等候替补的客户名单(包括姓名、所需票量); (2)系统能实现的操作和功能如下: ①录入:可以录入航班情况,全部数据可以只放在内存中,最好存储在文件中; ②查询航线:根据旅客提出的终点站名输出下列信息:航班号、飞机号、星期几飞行,最近一天航班的日期和余票额; ③承办订票业务:根据客户提出的要求(航班号、订票数额)查询该航班票额情况,若尚有余票,则为客户办理订票手续,输出座位号;若已满员或余票额少于订票额,则需重新询问客户要求。若需要,可登记排队候补;

2017-06-07

空空如也

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

TA关注的人

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