摘要: 对一个下标在 [l,r][l,r][l,r] 间的数组 aaa 排序。 一般可以这么调用:gsort(a,1,n),把 a1∼na_{1\sim n}a1∼n​ 排好序。 int r[N]; void gsort(int *a,int x,int y){ if(x==y) return; int m 阅读全文
posted @ 2021-08-28 23:36 luckydrawbox 阅读(6) 评论(0) 推荐(0)
摘要: 对一个下标在 [l,r][l,r][l,r] 间的数组 aaa 排序。 一般可以这么调用:ksort(a,1,n),把 a1∼na_{1\sim n}a1∼n​ 排好序。 void ksort(int *a,int l,int r){ int i=l,j=r,f=a[(l+r)/2]; do{ wh 阅读全文
posted @ 2021-08-28 23:30 luckydrawbox 阅读(8) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> #define ll long long using namespace std; long long read(){ long long x=0,f=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='- 阅读全文
posted @ 2021-08-28 23:17 luckydrawbox 阅读(9) 评论(0) 推荐(0)
摘要: 目录 常用程序模板 快读快写 离散化 重载运算符 文件输入输出 back 阅读全文
posted @ 2021-08-28 23:14 luckydrawbox 阅读(12) 评论(0) 推荐(0)
摘要: 这个还用说吗。 freopen("sth.in","r",stdin); freopen("sth.out","w",stdout); back 阅读全文
posted @ 2021-08-28 23:09 luckydrawbox 阅读(16) 评论(0) 推荐(0)
摘要: 把长度为 nnn 的 aaa 数组映射成只有 1∼tot1\sim tot1∼tot 的整数的 bbb 数组,其中返回值 tottottot 是 aaa 中元素个数。 int discrete(int n,int *a){ int b[N]; for(int i=1;i<=n;i++) b[i]=a 阅读全文
posted @ 2021-08-28 23:07 luckydrawbox 阅读(9) 评论(0) 推荐(0)
摘要: 结构体内 struct asdf{ int x, y; bool operator<(const asdf &a)const{ return x<a.x||(x==a.x&&y<a.y); } }; 结构体外 bool operator<(const int &a,const int &b){ re 阅读全文
posted @ 2021-08-27 23:44 luckydrawbox 阅读(13) 评论(0) 推荐(0)
摘要: 目录 快速幂 龟速乘 高精度 矩阵 质数 约数 同余 高斯消元 线性基 组合计数 莫比乌斯函数 二进制运算 康托展开 扩展卢卡斯定理 扩展 BSGS 二次剩余 多项式 类欧几里得算法 back 阅读全文
posted @ 2021-08-27 23:13 luckydrawbox 阅读(8) 评论(0) 推荐(0)
摘要: 莫比乌斯函数,记作 μ(N)\mu(N)μ(N)。 当 NNN 包含相等的质因子时,μ(N)=0\mu(N)=0μ(N)=0。 当 NNN 的所有质因子各不相等且 NNN 有偶数个质因子时,μ(N)=1\mu(N)=1μ(N)=1。 当 NNN 的所有质因子各不相等且 NNN 有奇数个质因子时,μ( 阅读全文
posted @ 2021-08-27 23:01 luckydrawbox 阅读(9) 评论(0) 推荐(0)
摘要: 排列数 Anm/PnmA_n^m/P_n^mAnm​/Pnm​ long long A(long long m,long long n,long long mod){ long long ans=1; for(long long i=n-m+1;i<=n;i++) ans=ans*i%mod; re 阅读全文
posted @ 2021-08-27 22:51 luckydrawbox 阅读(20) 评论(0) 推荐(0)