- 博客(12)
- 收藏
- 关注
原创 快排
#include<bits/stdc++.h> using namespace std; int a[100005]; void qsort(int l,int r) { int i,j,mid,p; i=l;j=r; mid=a[(l+r)/2]; do { while(a[i]<mid) i++; while(a[j]>mid) j--; if...
2019-11-27 14:01:51
226
1
原创 欧拉环
#include<bits/stdc++.h> using namespace std; int cir[1005]={0},g[105][105]={0},m,n,pos=0; void dfs(int i) { for(int j=1;j<=n;j++) { if(g[i][j]==1) { g[i][j]=0; g[j][i]=0; dfs(...
2019-11-26 22:02:38
547
原创 kruskal
#include<bits/stdc++.h> using namespace std; int n,m,f[5001]; struct node { int pre; int next; int v; }a[200001]; bool cmp(node x,node y) { return x.v<y.v; } int find(int x) { if(f[x]!=...
2019-11-26 21:58:46
136
原创 prime
#include<bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; int n,m,ans=0,mp[5001][5001]; int lowcost[5001]; bool vis[5001]; void prime(int n) { for(int i=2;i<=n;i++) { lowcost[i...
2019-11-26 21:58:07
168
原创 dijkstra
#include<bits/stdc++.h> using namespace std; const int inf=2147483647; int dis[10001],pre[10001],n,m,st; int mp[10001][10001]; void dij(int v0) { bool vis[10001]; for(int i=1;i<=n;i++) { ...
2019-11-26 21:56:40
125
原创 spfa
#include<bits/stdc++.h> using namespace std; vector<int>edge[10005]; int n,m,s,end; int dis[10005]; void vis[10001]; const int inf=2147483646; void spfa() { queue<int> q; for(int ...
2019-11-26 21:55:28
117
原创 并查集
#include<bits/stdc++.h> using namespace std; int n,m; int f[10005]; int find(int x) { if(f[x]!=x) f[x]=find(f[x]); return f[x]; } int hebin(int x,int y) { f[y]=x; } main() { cin>>n...
2019-11-26 21:54:31
121
原创 二分答案
#include<bits/stdc++.h> using namespace std; bool judge(long long ww) { if(满足条件) return true; else return false; } int main() { while(l<=r) { mid=(l+r)/2; if(judge(mid)) l=mid+1; ...
2019-11-26 21:53:34
173
原创 快速幂
#include<bits/stdc++.h> using namespace std; long long b,a,p,k,ans=1,c; int main() { cin>>b>>p>>k; a=b;c=p; if(p==0) { ans=1%k; } while(p>0) {...
2019-11-26 21:49:43
96
原创 素数筛
#include<bits/stdc++.h> using namespace std; const int maxn=10000005; int n,m; int a[maxn]; bool prime[maxn]; void getlist(int n) { for(int i=1;i<=n;i++) prime[i]=1; prime[...
2019-11-26 21:48:51
131
原创 网络流
#include<iostream> #include<cstdio> #include<queue> #include<cstring> using namespace std; const int maxn = 300; const int MAX_INT = ((1 << 31) - 1); int n; ...
2019-11-26 21:46:11
116
原创 string
#include<bits/stdc++.h> using namespace std; int main() { //四种初始化 string str1;//为空 string str2("word");//word string str3(9,'a');//9个"a" string str4(str1);//为空 //输入 cin>>str1;...
2018-10-05 11:45:58
173
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅