随笔分类 -  基础算法模板

摘要:#include #include #define INF 0x3f3f3f3f using namespace std; int edge[105][105],d[105]; int Dijstra(int st,int n) { int mark[105],minn,minn_num; memset(mark,0,sizeof(mark)); for(int i=1;... 阅读全文
posted @ 2019-05-08 22:14 Leozi 阅读(109) 评论(0) 推荐(0)
摘要:#include #include #include #include typedef long long ll; using namespace std; ll sum[500050],n; struct node{ ll lf; ll rg; }a[500050]; ll cmp(node x,node y) { if(x.lf==y.lf) retu... 阅读全文
posted @ 2019-05-08 22:13 Leozi 阅读(248) 评论(0) 推荐(0)
摘要:#include using namespace std; long long min(long long x1,long long y1,long long z1,long long w1) { long long k1,k2; k1=min(x1,y1); k2=min(z1,w1); return min(k1,k2); } int main() { ... 阅读全文
posted @ 2019-05-08 22:12 Leozi 阅读(170) 评论(0) 推荐(0)
摘要:#include using namespace std; int par[1005]; int get_par(int x) { return par[x]==x?x:get_par(par[x]); } int main() { int T,n,m,x,y,cont; cin>>T; while(T--) { cin>>n>>m; ... 阅读全文
posted @ 2019-05-08 22:12 Leozi 阅读(117) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; typedef long long LL; LL work(LL n) { LL ans = 0; for(int k = 0; k >n) cout #include #include using namespace std; typede... 阅读全文
posted @ 2019-05-08 22:11 Leozi 阅读(711) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { /*map mp; map::iterator it; mp[2]='L'; mp[1]='A'; mp[3]='Z'; for(it=mp.begin();it!=mp.end();it++) { coutfirstse... 阅读全文
posted @ 2019-05-08 22:08 Leozi 阅读(186) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; int main() { int m,n,x; /*vector a; for(int i=0;i>x; a.push_back(x); } for(int i=0;i a[100]; cin>>m>>n; for(int i=0... 阅读全文
posted @ 2019-05-08 22:07 Leozi 阅读(613) 评论(0) 推荐(0)
摘要:#include using namespace std; int a[2005]; int main() { int quicksort(int r,int l); int n,i; while(cin>>n) { if(n==0) { break; } for(i=0;i>... 阅读全文
posted @ 2019-05-08 22:06 Leozi 阅读(120) 评论(0) 推荐(0)
摘要:#include #include #include #define N 50005 using namespace std; int maxx[N][20],minn[N][20],a[N]; int ST(int n) { for(int i=1;i>n>>q; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); ... 阅读全文
posted @ 2019-05-08 22:06 Leozi 阅读(200) 评论(0) 推荐(0)
摘要:c语言中 函数 log(x) 表示是以e为底的自然对数,即 ln(x) 函数 log10(x) 以10为底的对数,即 lg(x) 以其它数为底的对数用换底公式来表示 log(a)/log(b) 函数 log() 和 log10() 包含在头文件<math.h>中 阅读全文
posted @ 2019-05-08 22:05 Leozi 阅读(5673) 评论(0) 推荐(0)
摘要:#include #include int u,n; char a[1005],b[1005],h[1005]; int x[1005],y[1005],z[1005]; int main() { char s(char t[],char o[]); int p,q,i; while(scanf("%d",&n,n!=0)) { for(i=0;iN) ... 阅读全文
posted @ 2019-05-08 22:04 Leozi 阅读(321) 评论(0) 推荐(0)
摘要:struct Complex { double r,i; Complex(double _r = 0,double _i = 0) { r = _r; i = _i; } Complex operator +(const Complex &b) { return Complex(r+b.r,i+b.i); }... 阅读全文
posted @ 2019-05-08 22:03 Leozi 阅读(191) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int mapp[2005][2005],color[2005],n; int dfs(int x,int c) { color[x]=c; for(int i=1;i>T; while(T--) { cin>>n>>m; memset(mapp,0,si... 阅读全文
posted @ 2019-05-08 22:02 Leozi 阅读(377) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std; int mapp[2005][2005],color[2005]; int n,m,k; int bfs(int x) { color[x]=1; queue que; que.push(x); while(!que.empty()) { ... 阅读全文
posted @ 2019-05-08 22:01 Leozi 阅读(500) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; char map[105][105]; int b[105][105]; int m,n; int s[4][2]={-1,0,1,0,0,-1,0,1}; struct node{ int x,y; int step; }; int cheak(int x,int y) { ... 阅读全文
posted @ 2019-05-08 22:00 Leozi 阅读(129) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; typedef long long LL; int tree[32*100005][2]; LL val[32*100005]; int tot; void First() { memset(tree[0],0,sizeof(tree[0])); tot=1; } void inser... 阅读全文
posted @ 2019-05-08 21:59 Leozi 阅读(331) 评论(0) 推荐(0)
摘要:二位数组实现01背包算法: 一维数组实现01背包算法: 01背包取的物品是那些,取物品路径,价值,容量: 阅读全文
posted @ 2019-05-08 21:57 Leozi 阅读(194) 评论(0) 推荐(0)