上一页 1 ··· 4 5 6 7 8 9 下一页
摘要: bool cmp(char a[10],int l1,char b[20],int l2){ for(int i=0;i<min(l1,l2);i++){ if(a[i]!=b[i]){ return a[i]<b[i];//按字典序 } } return l1<l2;//如果相同长度中a[10] 阅读全文
posted @ 2021-02-08 23:07 DReamLion 阅读(414) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<cstdio> #include<cstring> #define ll long long #define mod 998244353 #define maxn 100010 #define jin 26//进制 using namespac 阅读全文
posted @ 2021-02-08 23:06 DReamLion 阅读(54) 评论(0) 推荐(0) 编辑
摘要: Kruskal算法 算法描述: 把所有边从小到大排序,能加就加,用并查集维护联通性,如果一个边两边的点已经在同一个连通块里了就不要这条边了 时间复杂度O(mlogm) code: #include<iostream> #include<cstdio> #include<algorithm> #def 阅读全文
posted @ 2021-02-07 22:47 DReamLion 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 概念: 初始状态所有点自成一个集合 包括两个基本操作: 1.把两个集合合并成一个大集合 2.查询点x和y是否属于同一个集合 优化: 按秩合并: 维护树的深度size,把深度小树的当儿子,将其根节点作为深度较大的树的树根的子节点合并 时间复杂度O(logn) 路径压缩: 找到x的根节点后,把路径上所有 阅读全文
posted @ 2021-02-07 14:16 DReamLion 阅读(33) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<cmath> #include<cstdio> #include<cstdlib> #define maxn 100010 #define maxm 2000010 using namespace std; template<typename 阅读全文
posted @ 2021-02-06 23:15 DReamLion 阅读(40) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; int n,tot,a[1010],c[1010]; int main(){ cin>>n; for(int 阅读全文
posted @ 2021-02-05 23:59 DReamLion 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 试除法判定质数 /*试除法判定质数*/ bool isprime(int x){ if(x<2) return false; for(int i=2;i<=x/i;i++) if(x%i==0) return false; return true; } 试除法分解质因数 /*试除法分解质因数*/ v 阅读全文
posted @ 2021-02-04 21:18 DReamLion 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 模板: #include<iostream> #include<cstdio> #define maxn 10010 using namespace std; template<typename T> inline void read(T &x){ x=0; bool flag=0; char c= 阅读全文
posted @ 2021-02-03 23:59 DReamLion 阅读(48) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> #define maxn 30 using namespace std; int n,f[maxn],a[maxn]; int ans=0; void LIS(){ for(int i=1;i<=n;i++){ f[i]=1; for(int j=1; 阅读全文
posted @ 2021-02-03 23:57 DReamLion 阅读(48) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> #include<cstdio> using namespace std; int p,q,x,y; int exgcd(int a,int b,int &x,int &y){//a*x+b*y=gcd(a,b) if(b==0){ x=1; y=0; retu 阅读全文
posted @ 2021-02-03 08:19 DReamLion 阅读(50) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 下一页