![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
板子
zsyanna
这个作者很懒,什么都没留下…
展开
-
欧拉筛筛素数
#include<cstring>#include<cstdio>bool a[10000005],f=0;int p[10000005]={0},tot=0;void pd(int n){ int i,j; memset(a,1,sizeof(a)); a[1]=0; for (i=2;i<=n;i++) { if (a[i]) p[++to...原创 2019-11-14 14:30:38 · 97 阅读 · 0 评论 -
P1337 [JSOI2004]平衡点 / 吊打XXX
#include <iostream>#include<cstdio>#include<cmath>#include<algorithm>#define down 0.996 using namespace std;struct node{ int x; int y; int w;}obj[2005];int n;doubl...原创 2019-11-12 21:55:32 · 112 阅读 · 0 评论 -
树链剖分
#include<cstdio>#include<iostream>#define lc(x) x<<1#define rc(x) x<<1|1using namespace std;const int MAXN=1e6+5;int n,m,rt,mod,cnt,tot,a[MAXN],head[MAXN];int fa[MAXN],t...原创 2019-11-12 21:08:39 · 76 阅读 · 0 评论 -
kruskal
int father(int x){ if (fa[x]!=x) fa[x]=father(fa[x]); return fa[x];}void unionn(int x,int y){ int f1,f2; f1=father(x); f2=father(y); if (f1==f2) return; else fa[f2]=f1;}bool cmp(node a,nod...原创 2019-11-06 21:23:18 · 103 阅读 · 0 评论 -
快速幂
void quicksort(int a,int b,int p)//求a^b%p{ int ans=1; while (b) { if (b&1==1) ans=ans*a%p; a=a*a%p; b/=2; } return ans;}原创 2019-11-06 20:33:29 · 70 阅读 · 0 评论 -
SPFA
标准SPFAvoid spfa(){ memset(dis,0x3f,sizeof(dis)); memset(v,0,sizeof(v)); dis[1]=1; v[1]=1; while (q.size()) { int x=q.front(); q.pop(); v[x]=0; for (int i=head[x];i;i=edge[i].next) { ...原创 2019-11-06 20:28:41 · 184 阅读 · 0 评论 -
快读
快读程序inline int read(){ int x=0,f=1; char ch=getchar(); while (ch<='0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); } while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=ge...原创 2019-11-06 20:16:48 · 124 阅读 · 0 评论 -
拓扑排序
void tpsort(){ queue<int> q; for (int i=1;i<n;i++) { if (ru[i]==0) q.push(i); } while (!q.empty()) { int u=q.front(); q.pop(); ...原创 2019-11-06 20:10:48 · 64 阅读 · 0 评论 -
Dijkstra+堆优化
#include&amp;lt;iostream&amp;gt;//边长为非负数,dis[n]从起点到n的最短路#include&amp;lt;cstdio&amp;gt;#include&amp;lt;algorithm&amp;gt;#include&amp;lt;cstring&amp;gt;#include&amp;lt;queue&原创 2018-10-21 21:34:36 · 162 阅读 · 0 评论 -
随机数
1. 库#include<random>2. 初始化srand((unsigned)time(NULL)); srand((unsigned)time(0)); //放在for循环之前,否则会很慢3. 产生一定范围随机数整数(rand()%(b-a))+a+1; //获得(a,b)的随机数(rand()%(b-a))+a; //获得[a,b)的随机数(ran...原创 2018-11-04 20:57:02 · 1919 阅读 · 0 评论 -
对拍
暴力程序正解程序注意:暴力程序和正解的读入是一个文件,但输出应是两个文件!random程序以此程序的输出生成暴力程序和正解程序的读入文件,所以freopen应写为:freopen(" .in","w",stdout);对拍程序背掉就好,真的:#include&lt;iostresam&gt;#include&lt;cstd原创 2018-11-04 21:19:12 · 148 阅读 · 0 评论