上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页
摘要: 1 //线段树的节点 2 //节点包括两部分信息,基本域,和信息域 3 //基本域:左右边界ld,rd. 左右孩子:lc,rc 4 //信息域:key值,如RMQ问题中,信息域中存储的是区间最大值 5 struct Node{ 6 int ld,rd; 7 Node *lc,*rc; 8 int key; 9 };10 11 //空树的建立,内含key值的初始化;12 //一般在主函数中首先调用 Node* root= buildtree(1,n);建立一棵新树13 Node *buildtree(int a,int b){14 Node * p=new ... 阅读全文
posted @ 2013-04-09 22:03 萧凡客 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1. 概述RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在i,j之间的最小/大值。这两个问题是在实际应用中经常遇到的问题,下面介绍一下解决这两种问题的比较高效的算法。当然,该问题也可以用线段树(也叫区间树)解决,算法复杂度为:O(N)~O(logN),这里我们暂不介绍。2.RMQ算法对于该问题,最容易想到的解决方案是遍历,复杂度是O(n)。但当数据量非常大且查询很频繁时,该算法无法在有效的时间内查询出正解。本节介绍了一种比较高效的在线算法(ST算法 阅读全文
posted @ 2013-04-09 21:59 萧凡客 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 4 char a[1000010]; 5 char b[10010]; 6 int next[10010]; 7 int A,B; 8 void getnext() 9 {10 int i=0,j=-1;11 next[0]=-1;12 while(i<B)13 {14 if(j==-1||b[i]==b[j]) next[++i]=++j;15 else j=next[j];16 }17 }18 19 int kmp_i()... 阅读全文
posted @ 2013-04-09 21:47 萧凡客 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 5 char a[12]; 6 char b[12]; 7 8 int f() 9 {10 int i,n,t=0;11 n=strlen(a);12 for(i=0;i<n;i++)13 t=t*26+(a[i]-'A'+1);14 return t;15 16 }17 char* v()18 {19 int i,j,t,n;20 char c[1... 阅读全文
posted @ 2013-04-08 11:23 萧凡客 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 char str[1005]; 5 int start; 6 char s[50],ss[50];int i,j; 7 double Term();double Expression();double Factor(); 8 double Term() 9 { 10 double f=Factor(),t; 11 --start; 12 if(str[start]=='*') 13 { ... 阅读全文
posted @ 2013-04-06 17:00 萧凡客 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<queue> 3 #include<string.h> 4 using namespace std; 5 6 int c[2][3]; 7 int v[100][100]; 8 typedef struct 9 {10 int vis[3];11 int deep;12 }node;13 14 int fun()15 {16 int i,j,at;17 queue <node> q;18 node n,t;19 memset(v,0,sizeof(v));20 n.vis... 阅读全文
posted @ 2013-04-06 16:30 萧凡客 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Office办公软件考试试题题目课程名称Office 办公自动化(XHKC-ZY-002)题型单选题题目在选定了整个表格之后,若要删除整个表格中的内容,以下哪个操作正确( )选择A单击“表格”菜单中的“删除表格”命令选择B按Delete键选择C按Space键选择D按Esc键答案B题目艺术字对象实际上是( )选择A文字对象选择B图形对象选择C链接对象选择D既是文字对象,也是图形对象答案B题目在Excel 2003 中,进行分类汇总之前,我们必须对数据清单进行( )选择A筛选选择B排序选择C建立数据库选择D有效计算答案B题目Word 2003 中对文档分栏后,若要使栏尾平衡,可在最后一栏的栏尾插入 阅读全文
posted @ 2013-04-06 15:24 萧凡客 阅读(10255) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 3 int fun(int n,int p) 4 { 5 int a,t; 6 if(p==0) return 1; 7 if(p==1) return n; 8 a=fun(n,p/2); 9 t=a*a%10003;10 if(p&1)11 t=t*n%10003;12 return t;13 }14 15 int main()16 {17 int n,m,t,i,sum;18 scanf("%d",&t);19 while(t--)20 ... 阅读全文
posted @ 2013-04-06 15:19 萧凡客 阅读(401) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 3 int a[32][32]; 4 int m; 5 6 int fun() 7 { 8 int i,j,k; 9 for(i=0;i<m;i++)10 if(a[i][i]!=0) return 1;11 12 for(i=0;i<m;i++)13 for(j=0;j<m;j++)14 if(i!=j)15 if(a[i][j]<=0) return 2;16 17 for(i=0;i<m;i++)18 ... 阅读全文
posted @ 2013-04-06 11:47 萧凡客 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 3 int a[4][4]; 4 typedef struct 5 { 6 int x; 7 int y; 8 }node; 9 node s[10]; 10 11 void cs()//用来存放数字的结构体,x,y分别是他们的行列坐标 12 { 13 s[0].x=3;s[0].y=1; 14 s[1].x=0;s[1].y=0; 15 s[2].x=0;s[2].y=1; 16 s[3].x=0;s[3].y=2; 17 s[4].x=1;s[4].y=0; 18 ... 阅读全文
posted @ 2013-04-06 11:26 萧凡客 阅读(158) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 下一页