08 2014 档案
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=seach小P的故事——神奇的Dota#include #include #include int V; int f[100001]; int c[3] = {0,150,200,350...
阅读全文
摘要:#include using namespace std;const int N = 3;//物品个数const int V = 5;//背包最大容量int weight[N + 1] = {0,3,2,2};//物品重量int value[N + 1] = {0,5,10,20};//物品价值in...
阅读全文
摘要:重要概念有向边,无向边,序偶,零图(仅有孤立节点组成的图),平凡图(仅有一个节点组成的图),环(自回路)(关联于同一节点的边)度数,入度,出度,度数和边数的关系,度数为奇数的节点必定为偶数个。入度和出度的关系多重图(含有平行边)简单图(不包含平行边和环)完全图的边数 e = 1/2 *n*(n-1)...
阅读全文
摘要:最短路问题是一种常见的问题,她一般被描述为包含n个点和m,主要分为两类:(1)(单源最短路径)求解从起点s到终点e的最短路径(2)(多源最短路径)求解图中任意两点的最短路径。常用的解题算法有四种:Dijkstra,bellman-ford,spfa,Floyd
阅读全文
摘要:#include #include #include #include #define INF 0x3f3f3f3fusing namespace std;struct node{ int u,v,w,next;}edge[150001];int head[30001],dis[30001],...
阅读全文
摘要:http://www.cnblogs.com/khbcsu/p/3877659.html
阅读全文
摘要:#include #include #include #includeusing namespace std;const int N=300;const int MAXE=200000;const int inf=10&&d[u]+edge[j].w#include #include #includ...
阅读全文
摘要://连续最短路径算法//消圈算法//先求最大流, 再在Gf中寻找负费用圈并沿它增广//KM算法//二分图的最优匹配 短距离图优势很大//ZKW算法//KM+SAP(Shortest Augmenting Path最短增广路)//原始对偶(Primal-Dual)算法//S 源点 T汇点 n点的个...
阅读全文
摘要:#include#include#define N 111char str[N][N];int a,b;int dir[8][2]= {1,1,1,-1,-1,1,-1,-1,0,1,0,-1,1,0,-1,0}; //因为是上下左右和斜对角,所以是八个方向。void fbs(int x,int y...
阅读全文
摘要:我对边表的理解和边表的建立://结构struct node{ int u,v,w; int next;}g[M];int head[N],t = 0;//初始化void init(){ t = 0; memset(head,-1,sizeof(head));}//加边void...
阅读全文
摘要:#include #include #include #include #include #include #include #include #include #include #include using namespace std;const int INF=0x3f3f3f3f;int he...
阅读全文
摘要:#include#include#include#include#includeusing namespace std;int pre[500],flow[500][500],dis[500];int map[500][500];int maxflow;int n,m;int ek(int begi...
阅读全文
摘要:http://wenku.baidu.com/view/7ed3c241a8956bec0975e32b.html
阅读全文
摘要:KMP :http://www.cnblogs.com/dolphin0520/archive/2011/08/24/2151846.html
阅读全文
摘要:#include#includechar s1[1000005],s2[1000005];int next[1000005];void get_next(char s[1000005]){ int i = 0; int len = strlen(s); next[0] = -1;...
阅读全文
摘要://BF 算法int BFmatch(char *s,char *p){ int i,j; i = 0; while(i<strlen(s)) { j = 0; while(s[i] == p[j] && j<strlen(p)) {...
阅读全文
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=232#problem/BWe all know that a pair of distinct points on a plane defines a line and that ...
阅读全文
摘要:#include #include #include using namespace std;struct node{ int l,r; int c; double cnt,lf,rf;}seg[603];double y[201];struct Line{ double x...
阅读全文
摘要:#include #include using namespace std;int a[10];int main(){ int i; for(i = 0;i#include using namespace std;int cmp(int a,int b){ return a>b;}...
阅读全文
摘要:#include#include#includeusing namespace std;#define N 1002int map[N][N];int main(){ int i,j,m,n,Min,area,high,t,k; char c[100]; scanf("%d",&t...
阅读全文
摘要:#include #include #include #include using namespace std;#define N 100002struct node{ int l,r; long long lz,w;}q[4*N];void pushup(int rt){ q[r...
阅读全文
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=221#problem/C#include #includestruct Node{ int sum; int l,r;} node[800001];int num[20...
阅读全文
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=221#problem/A#include #include struct seg{ int l; int r; int sum;}q[2000001];int n...
阅读全文
摘要:D -C Looooopshttp://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=212#problem/D#include #includeusing namespace std;long long exgcd(long long a,...
阅读全文
摘要:http://www.cnblogs.com/Lyush/p/3415429.html
阅读全文
摘要:1.求gcd,算法为欧几里德(辗转相除法)2.解一元二次方程,算法为扩展欧几里德3.求素数,算法为埃氏筛法4.快速进行幂运算,算法快速幂(反复平方)5.解线性同余方程,求逆元(基于exgcd)6.其它用来优化模运算的定理,欧拉定理(费马小定理),相应的函数欧拉函数
阅读全文
摘要:#include #include long long gcd(long long x,long long y){ if(y==0) { return x; } return gcd(y,x%y);}void extended_gcd(long long a,l...
阅读全文
摘要:#includeint extended_gcd(int a,int b,int &x,int &y){ int r,t; if(!b) { x = 1; y = 0; return a; } r = extended_gcd(...
阅读全文
摘要:#include #include #include #include using namespace std;int a[1000001];int prime[1000001];int main(){ int k,tt=0; int p; a[0]=a[1]=0; a[2...
阅读全文
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=203#problem/C/*#include #include #include using namespace std;struct node{ int x,y;}q1;i...
阅读全文
摘要:http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=203#problem/A#include #include #include #include #includeusing namespace std;int a[10001],n...
阅读全文
摘要:1.简介STL=StandardTemplateLibrary,标准模板库,惠普实验室开发的一系列软件的统称。它是由AlexanderStepanov、MengLee和DavidRMusser在惠普实验室工作时所开发出来的。这可能是一个历史上最令人兴奋的工具的最无聊的术语。从根本上说,STL是一些“...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2896#include #include #include struct node{ int u,v,w;}q[200001];int bin[500...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2894谈一下对贝尔曼福特的认识(参考别人的)BF是对边进行操作,dijkstra 是对点进行操作,N个顶点的最短路最多是N-1条边,所以需要循环N-1次1....
阅读全文