ICPC竞赛模板
Hiahiahia~
悲伤的牛奶
保持努力,保持乐观。
展开
-
Manacher算法模板
char s[maxn], Ma[maxn*2];int p[maxn*2];//p[i]表示在Ma数组中, 以i为中心的最长回文子串半径void Manacher(char s[], int len){ int l = 0; Ma[l++] = '$', Ma[l++] = '#'; rep(i, 0, len - 1){ Ma[l++] = s[i]; Ma[l++] ...原创 2019-04-27 23:03:56 · 170 阅读 · 0 评论 -
线段树模板
整理一下线段树模板。因为学的不精,复杂度是在我能力范围内最优的,以后学会了更优秀的再说吧。分两块:1:单点修改,区间查询2:区间修改,区间查询其实线段树的变种挺多的,这两个放在这方便修改。我还是比较喜欢写成结构体的形式。。1:单点修改,区间查询#define lson i << 1#define rson i << 1 | 1te...原创 2019-05-09 16:17:59 · 200 阅读 · 0 评论 -
每日一题 2019/4/8
今天就整理模板吧感谢牛逼网友的帮助,有了这些模板整理工具:https://github.com/4thcalabash/code_libraryhttp://www.planetb.ca/syntax-highlight-wordhttps://www.cnblogs.com/palayutm/p/6444833.html#e5898de8a880_2https://githu...原创 2019-04-08 20:18:52 · 334 阅读 · 0 评论 -
KMP模板
//主串a, 模式串bchar a[maxn], b[maxn];int nxt[maxn];int la, lb;void getNext(){ int j = 0; rep(i, 2, lb){ while(j && b[i] != b[j+1]) j = nxt[j]; if(b[j+1] == b[i])j++; nxt[i] =...原创 2019-05-03 14:24:38 · 143 阅读 · 0 评论 -
快速读入、输出模板
inline int read(){ char ch = getchar(); int x = 0, f = 1; while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); } while('0' <= ch && ch <= '9'){ x = x * 10...原创 2019-04-02 12:48:07 · 253 阅读 · 0 评论 -
蔡勒公式求任意日期是星期几
原理不谈,直接百度“蔡勒公式”,本文直接谈代码实现(c++)传入年月日,返回的就是星期几了int Day(int year, int month, int day){ int ret = 0; int c, y, m, d; if(month <= 2){ c = ( year - 1 ) / 100; y = ( year - 1 ) % 100; m = mo...原创 2018-12-19 14:29:03 · 361 阅读 · 0 评论 -
欧拉函数模板
#include<bits/stdc++.h>#define rep(i, a, b) for(int i = a; i <= (b); i++)const int maxn = (int)1e5 + 5;using namespace std;//单个数的欧拉函数值int Euler(int n){ int ret = n; int m = sqrt(n);...原创 2018-11-17 15:40:52 · 160 阅读 · 0 评论 -
进制转换
汇编课好无聊啊,随便写写给一个十进制数,转换成其他任意2-16进制数思路很简单,取模,倒序输出如何倒序?可以用stack,也可以用dfsCode:#include<set>#include<map>#include<cmath>#include<ctime>#include<queue>#include&l...原创 2018-09-05 23:09:28 · 170 阅读 · 0 评论 -
使用c++11生成随机数
c++的rand()函数只能生成小于3e4(int16)的随机数,很多时候不够用使用rand() * rand()实际上也不符合分布update:以前的删了,都没初始化种子,以后就用这个吧。#include<chrono>mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count());...原创 2018-09-25 21:37:40 · 434 阅读 · 0 评论 -
个人头文件、预操作
#include<set>#include<map>#include<cmath>#include<ctime>#include<queue>#include<stack>#include<cstdio>#include<string>#include<vector>#i...原创 2018-11-02 21:31:30 · 572 阅读 · 3 评论 -
矩阵快速幂模板
啥也不会,先传板子可AC POJ3070 POJ3070#include<set>#include<map>#include<stack>#include<cmath>#include<queue>#include<cstdio>#include<string>#include&原创 2018-07-28 20:59:46 · 176 阅读 · 0 评论 -
快速幂(取模)
typedef long long ll;const int mod = (int)1e9 + 7;ll qpow(ll x, ll y){ ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod){ if(y & 1) ret = (ret * x) % mod; } return ret;}原创 2018-04-12 16:12:58 · 205 阅读 · 0 评论 -
并查集模板(裸)
int fa[maxn];int n;int Find(int x){ return x == fa[x] ? x : fa[x] = Find(fa[x]);}void uni(int x, int y){ fa[Find(x)] = Find(y);}void init(){ rep(i, 0, n) fa[i] = i;}原创 2018-07-28 20:51:56 · 268 阅读 · 0 评论 -
树状数组模板
#define lowbit(x) x&(-x)int c[maxn];int getsum(int x){ int ret = 0; for( ; x > 0; ret += c[x], x -= lowbit(x)); return ret;}void update(int x, int val){ for ( ; x < maxn; c[x]...原创 2018-07-28 20:50:04 · 281 阅读 · 0 评论 -
计算组合数
一般有两种方法费马小定理ll fac[maxn]; ll qpow(ll x, ll y){ ll res = 1; while(y){ if(y & 1) res = (res * x) % mod; y >>= 1; x = (x * x) % mod; } return res;}void init(){//记得放到主函数里...原创 2018-07-28 10:17:11 · 666 阅读 · 1 评论