随笔分类 - 御用模板
摘要:费马小定理 #include<cstdio> #include<cstring> using namespace std; int Quick_Power(int a,int b,int c) { int ans=1; while(b) { if(b&1) ans=(1ll*ans*a)%c; a=
阅读全文
摘要:#define Max 1000001 int euler[Max]; void Init(){ euler[1]=1; for(int i=2;i<Max;i++) euler[i]=i; for(int i=2;i<Max;i++) if(euler[i]==i) for(int j=i;j<M
阅读全文
摘要:ll f[N],invf[N]; ll fpow(ll a,ll k){ ll res=1; while(k){ if(k&1) res=(res*a)%mod; k>>=1; a=a*a%mod; //cout<<1<<endl; } return res; } void init(int n){
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; struct st{ int num,val; }a[1000005]; deque<st>q; //最小值 deque<st>p; //最大值 int main(){ int n,k; cin>>n>>k;
阅读全文
摘要:#include<iostream> #include<vector> #include<cstdio> #include<cstring> using namespace std; typedef long long ll; const int maxn=200005; vector<int> t
阅读全文
摘要:#include<iostream> #include<vector> #include<string.h> #include<map> #include<string> #include<algorithm> #include<cstdio> using namespace std; #defin
阅读全文
摘要:substr()函数定义于头文件 <string> 一、参数:(pos, n)pos - 从此位置开始拷贝n - 拷贝 n 长度的字符串 二、形式:s.substr(pos, n) 三、解释:返回一个string,包含s中从pos开始的n个字符的拷贝。 #include<iostream> #inc
阅读全文
摘要:首先介绍一下什么是置换群,不说一些繁琐的概念。 首先给你一个序列,假如: s = {1 2 3 4 5 6} 然后给你一个变换规则 t = {6 3 4 2 1 5} 就是每一次按照t规则变换下去 比如这样 第一次:6 3 4 2 1 5 第二次:5 4 2 3 6 1 第三次:1 2 3 4 5
阅读全文
摘要:ll Pow(ll a, ll b){ ll ans = 1; while(b > 0){ if(b & 1){ ans = ans * a % mod; } a = a * a % mod; b >>= 1; } return ans; }
阅读全文
摘要:KMP算法中,求了一个前缀函数: 为前 个字符组成的子串中、真前缀、真后缀相等的最大长度。例如对于abcabcd a,,没有真前后缀。 ab, abc, abca, abcab, abcabc, abcabcd, 那么对于给出的字符串求 数组后,前后缀相等的最大长度即为 。并且只要途中出现过 ,就说
阅读全文
摘要:reverse() std:: void reverse(s.begin(), s.end());上面是原地反转的方法,如果需要反转到别的 string 里面,一样简单: s1.assign(s.rbegin(), s.rend());效率也相当理想。
阅读全文
摘要:#include<cstdio> #include<cstdlib> #include<ctime> //标准程序加 读入 输出 // freopen("radom.txt","r",stdin); // ofstream fout("test.txt"); // streambuf* pOld=c
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f #define Mod 100000007 typedef long long ll; #define N 2//这里表示2*2的矩阵//如果是3*3的 则可以令为
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; const int MAXN=1005; int Next[MAXN]; char str[MAXN],pattern[MAXN]; int cnt; int getFail(char *p,int plen)
阅读全文
摘要:主要是想得到p数组 对于p[i]有,以i为中心的回文串起始坐标为(i-p[i])/2;长度为 p[i]-1; #include<iostream> #include<string.h> #include<algorithm> using namespace std; char s[1000]; ch
阅读全文
摘要:#include<cstdio>#include<queue>using namespace std;int l[100001],tot,dis[100001],s,n,m;inline int read()//输入优化{ int d=1,f=0;char c; while(c=getchar(),
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; int main() { while(true) { puts(""); puts(" current file "); system("random.exe"); system("baoli.exe");
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int n,m; const int INF=0x3f3f3f3f; const int MAXN=110; bool vis[MAXN]; int lowc[MAXN]; int tu[MAXN][MAXN]
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; const int maxn=1010; const int inf=0x3f3f3f3f; int n,m; struct node{ int v,w; node(){ } node(int _v,int _
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int n,m; struct node{//结构体 int v,w; node(){ }; node(int _v,int _w){ v=_v; w=_w; } }; vector <node> g[1010
阅读全文

浙公网安备 33010602011771号