
模板
不要默认的人生
这个作者很懒,什么都没留下…
展开
-
堆优化迪杰斯特拉
#include<stdio.h>#include<algorithm>#include<queue>using namespace std;const int N=10000;int head[N],dis[N],to[N<<1],w[N<<1],nxt[N<<1];int cnt;int m,n;void ...原创 2020-01-28 14:53:14 · 221 阅读 · 0 评论 -
哈希表模板
struct H {static const int md=3999997;bool vis[md]; int dt[md], foo[md], s[md], top;void clr() { while(top) { int x=s[top–]; vis[x]=0, dt[x]=-1; } }void add(int a, int b) {int x=a%md;while(1) { ...原创 2020-01-08 14:28:21 · 222 阅读 · 0 评论 -
母函数模板
原始博客//初始化a,因为有last,所以这里无需初始化其他位a[0]=1;int last=0;for (int i=0;i<K;i++){ int last2=min(last+n[i]*v[i],P);//计算下一次的last memset(b,0,sizeof(int)*(last2+1));//只清空b[0..last2] for (int j=n1[i];j<...原创 2019-11-28 15:55:48 · 95 阅读 · 0 评论 -
扩展bsgs
#include<stdio.h>#include<map>#include<math.h>#define ll long longusing namespace std;struct H { static const int md=3999997; bool vis[md]; int dt[md], foo[md], s[md], t...原创 2019-11-27 00:18:26 · 129 阅读 · 0 评论 -
bsgs模板
bsgs算法bsgs算法,又称大小步算法(某大神称拔山盖世算法)。主要用来解决 A^x=B(mod C)(C是质数),都是整数,已知A、B、C求x。(poj 2417 Discrete Logging)具体步骤如下:先把x=i*m-j,其中m=ceil(sqrt©),(ceil是向上取整)。这样原式就变为A^(i*m-j)=B(mod C),再变为Aj×B=A(m*i) (mod ...转载 2019-11-25 21:03:46 · 211 阅读 · 0 评论 -
大素数检测
#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <time.h>#include <algorithm>typedef long long ll;...原创 2019-11-23 22:29:18 · 381 阅读 · 0 评论 -
spfa模板
#include "bits/stdc++.h"using namespace std;const int maxN = 200010 ;struct Edge{ int to , next , w ;} e[ maxN ];int n,m,cnt,p[ maxN ],Dis[ maxN ];int In[maxN ];bool visited[...原创 2019-11-13 19:12:54 · 132 阅读 · 0 评论