在幕布中查看(密码:LAN) 计算机数学 数制 转换 整数 ->:除K取余,逆序 <-:加权求和 小数 ->:乘二取整,顺序 <-:加权求和 计算 数据存储 机器数 真值 原码 最高位为符号位 反码 正数:=原码 负数:=原码符号位不变,其余位取反 补码 正数:=原码 负数:=反码+1 n位补码表示范围:[-2^(n-
在幕布中查看(密码:LAN) 网络 首个计算机网络:1969Arpanet,是Internet的前身 分类 拓扑结构 星型,环型,总线,分布,树型,网状,蜂窝 规模 局域网,城域网,广域网 协议与模型 OSI参考模型 结构 物理层:光纤、同轴电缆、双绞线、中继器和集线器 最重要、最基础的一层,它建立在传输媒介基础上,起建立
动态规划——多进程DP luogu1004 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 /* luogu1004 多进程DP */ #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; template<typename T> T Max(const T& a,const T& b){return a>b?a:b;} template<typename T> void read(T& w) { char r;int f=1; for(r=getchar();(r<48||r>57)&&r!='-';r=getchar()); if(r=='-')r=getchar(),f=-1; for(w=0;r>=48&&r<=57;r=getchar())w=w*10+r-48; w*=f; } const int maxn=13; int n; int a[maxn][maxn]; void input() { read(n); int x,y,z; for(read(x),read(y),read(z);x||y||z;read(x),read(y),read(z)) { a[x][y]=z; } } int f[maxn][maxn][maxn][maxn]; void dp() { for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) { for(int k=1;k<=n;++k) for(int l=1;l<=n;++l) { f[i][j][k][l] =Max( Max( f[i-1][j][k-1][l],f[i-1][j][k][l-1]),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 template<typename T> void Swap(T& a,T& b){T t=a;a=b;b=t;} template<typename T> void shift(T* ary,int k,int f,bool comp(const T& a,const T&b) ) { for(int son=k*2;son<=f;k=son,son=k*2) { if(son+1<=f&&comp(ary[son+1],ary[son])) ++son; if(comp(ary[son],ary[k])) Swap(ary[son],ary[k]); else break; } } template<typename T> void heapSort(T* ary,int l,int r,bool comp(const T& a,const T&b))//r不是超尾而是最后一个元素 { int mid=(l+r)/2; for(int i=mid;i>=l;--i) shift(ary,i,r,comp); for(int i=r;i>=l+1;--i) { Swap(ary[i],ary[l]); shift(ary,l,i-1,comp); } }
也谈八数码境界 题意 给定一个九宫格起始状态,其中八格放置1~8,有一格为空。空格可以和毗邻的格子交换,一次交换称为一次操作,求达到目标状态所需的最小字典序的最少操作次数及方案。 第一重:BFS+STL 略。 第二重:BFS+CantorHash Cantor 对所有1~n的排列按字典序进行排序得到一个序列,那么任意
输入输出效率对比 前言 在OI竞赛中,几乎每道题都需要进行文件的读写操作。然而在非常紧的时间限制内,读写的时间也至关重要。目前可供使用的标准输入输出操作有如下几种: cin/cout cin/cout+取消同步 scanf/printf 手写I/O优化 那么本文接下来将会对这几种方法进行简单的比较。 介绍 首先对各种输入输出方式给出简单的介绍。 cin/cout 这
队列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 template<typename T,int maxnode> struct QUE { T ary[maxnode]; int f,t; int cnt; QUE(){f=t=cnt=0;} void clear(){f=t=cnt=0;} bool empty(){return cnt==0;} void push(const T& w)//if t+1!=f { ary[t++]=w; if(t==maxnode)t=0; ++cnt; } T front(){return ary[f];} void pop() { ++f; if(f==maxnode)f=0; --cnt; } };
Tarjan——强连通分量&最近公共祖先(LCA) 写在前面:这是我高二时给高一学弟学妹们唯二的讲课之一。时光荏苒,如今我早已AFO,将讲课内容整理如下,也为了纪念共同奋斗于OI的那些人,那些时光。 写在前面的后面:时间仓促,不甚严谨,难免纰漏,敬请指正。 写在前面的后面的后面:下文中的一些概念可
二分图匹配 匈牙利最大匹配 邻接矩阵写法 例题:luogu3386 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 //luogu3386 二分图匹配 #include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; const int maxn=1003; int n,m,e; bool d[maxn][maxn]; void input() { scanf("%d%d%d",&n,&m,&e); for(int i=1;i<=e;++i) { int x,y; scanf("%d%d",&x,&y); if(y<=m) d[x][y]=true; } } int match[maxn]; bool used[maxn]; bool findPath(int k) { for(int i=1;i<=m;++i) { if(d[k][i]&&!used[i]) { used[i]=true; if((!match[i])||findPath(match[i])) { match[i]=k; return true; } } } return false; } int
单调队列 (以单调递增队列为例) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 template<typename T,int maxnode,bool comp(const T&,const T&) > struct upQUE { T ary[maxnode+1]; int f,t; int cnt=0; upQUE(){f=t=cnt=0;} void clear(){f=t=cnt=0;} bool empty(){return cnt==0;} T front(){return ary[f];} T tail(){return t==0?ary[maxnode]:ary[t-1];} void push(const T& w) { while(t!=f&&comp(w,tail())) { --t; if(t==-1)t=maxnode; } ary[t++]=w; if(t==maxnode+1)t=0; ++cnt; } void pop() { ++f; if(f==maxnode+1)f=0; --cnt; } };