建议用标题旁边打开的目录,更清晰明了!
太多了,编辑的时候要找好久,数据结构和图论都搬出去了,下面有链接。离数学搬家也不远了。
好了,数学也搬出去了。
头文件
纯粹方便用
#include
using namespace std;
int main(){
return 0;
}
读入、输出优化(必加!!!)
namespace IOBuf{
char gc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
int read(){
int sum=0,f=1;char a=gc();
while(a'9'){if(a=='-')f=-1;a=gc();}
while(a>='0' && a9) print(x/10);
putchar(char(48+x%10));
}
}
using namespace IOBuf;
点击查看代码
inline char gc(){
static char buf[100000], *p1 = buf, *p2 = buf;
return p1 == p2 && (p2 = (p1 = buf)
+ fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}
template inline
void read(T& x) {
T f = 1, b = 0; char ch = gc();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = gc();
} while (ch >= '0' && ch inline
void print(T x) {
if (x == 0) return putchar('0'), void();
if (x < 0) putchar('-'), x = -x;
int st[129] = {0}, k = 0;
while (x) st[++k] = x % 10, x /= 10;
for (int i = k; i; i--) putchar(st[i] + '0');
}
KMP
点击查看代码
#include
using namespace std;
const int N=1e6+5;
int nxt[N];
char a[N],b[N];
int main(){
scanf("%s%s",a+1,b+1);
int n=strlen(a+1),m=strlen(b+1);
for(int i=2,j=0;i
字符串哈希
点击查看代码
#include
using namespace std;
#define int long long
#define pii pair
#define mk make_pair
#define fi first
#define se second
const int p=133331,p2=917120411,p1=1e9+7,N=1e6+5;
pii hs[N],pre[N];
char a[N];
pii get(int l,int r){
int t1=hs[r].fi-hs[l-1].fi*pre[r-l+1].fi%p1;t1=(t1%p1+p1)%p1;
int t2=hs[r].se-hs[l-1].se*pre[r-l+1].se%p2;t2=(t2%p2+p2)%p2;
return mk(t1,t2);
}
signed main(){
int n,m;
scanf("%s%lld",a+1,&n);
m=strlen(a+1);
pre[0]=mk(1,1);
for(int i=1;i>x>>y>>c>>d;
if(d-c==y-x && get(x,y)==get(c,d)) cout<
马拉车(manacher)
点击查看代码
#include
using namespace std;
const int N=1.1e7+5;
int len[N<j) j=len[i]+i-1,ce=i;
ans=max(ans,len[i]-1);
}
cout<
AC 自动机
点击查看代码
#include
using namespace std;
#define se second
#define fi first
const int N=2e6+5;
struct node{
int end,fail,s[26];
};
node a[N];
int n,co;
void insert(string s){
int u=0;
for(int i=0;i q;
for(int i=0;i>n;
for(int i=1;i>s;insert(s);}
get_fail();
string s;cin>>s;
printf("%d",fi(s));
return 0;
}
快速幂
点击查看代码
inline int ksm(int x,int y,int p){
int res=1;
while(y){if(y&1)res=res*x%p;x=x*x%p,y>>=1;}
return res;
}
Original: https://www.cnblogs.com/yolanda-yxr/p/16448721.html
Author: _yolanda
Title: 模板集合
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/583827/
转载文章受原作者版权保护。转载请注明原作者出处!