随笔分类 -  必备(背)模板

模板总结
摘要:快排是一种不稳定的排序算法,但其平均时间复杂度是$O(nlog_2n)$,最坏情况为$O(n^2)$,所以该排序方法被认为是目前最好的一种内部排序方法。 话说$sort$不香吗 #include<iostream> #include<cstdio> #include<algorithm> using 阅读全文
posted @ 2020-09-25 19:01 _pwl 阅读(239) 评论(1) 推荐(0)
摘要:求$b^p$%k **递归版 😗* #include<iostream> #include<cstdio> #define ll long long using namespace std; inline void read(ll &x){ int f=1; x=0; char ch=getcha 阅读全文
posted @ 2020-09-18 19:29 _pwl 阅读(191) 评论(0) 推荐(0)
摘要:一、选择排序 for(int i=0;i<n;i++){ k=i; for(int j=i+1;j<n;j++){ if(a[j]<a[k]) k=j; } if(k!=i) swap(a[i],a[k]); } 时间复杂度:O(n^2) 稳定性:不稳定 二、冒泡排序(2.0版) bool flag 阅读全文
posted @ 2020-03-11 15:36 _pwl 阅读(284) 评论(1) 推荐(0)
摘要:inline int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b); } inline int lcm(int a,int b){ return a*b/gcd(a,b); } 阅读全文
posted @ 2020-02-27 16:20 _pwl 阅读(512) 评论(0) 推荐(0)
摘要:一、快速读入模板(int) inline void read(int &x){ int f=1; char ch=getchar(); x=0; while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<=' 阅读全文
posted @ 2020-02-26 11:52 _pwl 阅读(295) 评论(0) 推荐(0)

1 2 3
4