随笔分类 -  A模板

摘要:倍增维护RMQ,nlogn预处理,O(1)查询 include using namespace std; const int maxn = 1e5+7; struct RMQ{ const static int RMQ_size = maxn; int n; int ArrayMax[RMQ_siz 阅读全文
posted @ 2017-03-12 16:51 qscqesze 阅读(324) 评论(0) 推荐(0) 编辑
摘要:虽然这个队,以后再也没有了,但是他的模板,是永垂不朽的!【误 include __gnu_pbds::priority_queue Q; 优先队列,配对堆默认,从小到大! __gnu_pbds::priority_queue , pairing_heap_tag Q; __gnu_pbds::pri 阅读全文
posted @ 2016-11-26 00:12 qscqesze 阅读(792) 评论(0) 推荐(1) 编辑
摘要://233 模板 LCA void dfs(int x,int f){ for(int i=0;i=0;i ) { if(ddeep[y])swap(x,y); y=up(y,deep[y] deep[x]); if(x==y)return x; for(int i=maxm 1;i =0;i ) 阅读全文
posted @ 2016-08-10 09:41 qscqesze 阅读(423) 评论(0) 推荐(0) 编辑
摘要:fread读入挂 const int BUF=40000000; char Buf[BUF], buf=Buf; const int OUT=20000000; char Out[OUT], ou=Out;int Outn[30],Outcnt; inline void write(int x){ 阅读全文
posted @ 2016-08-04 14:58 qscqesze 阅读(2316) 评论(1) 推荐(1) 编辑
摘要:岛娘的无敌头文件 pragma comment(linker, "/STACK:36777216") // pragma GCC optimize ("O2") define LOCAL // include "testlib.h" include include include include i 阅读全文
posted @ 2016-07-27 09:51 qscqesze 阅读(1173) 评论(0) 推荐(2) 编辑
摘要:莫队的模板!!!!! 嘿嘿嘿 include using namespace std; const int maxn = 1000005; inline int read() { int x=0,f=1;char ch=getchar(); while(ch '9'||ch='0'&&chQ[i]. 阅读全文
posted @ 2016-07-08 16:38 qscqesze 阅读(452) 评论(0) 推荐(1) 编辑
摘要:http://166.111.121.20:9080/mathjournal/XUSJ200202/xusj200202010.caj.pdf 秋实大哥给我的,感觉很强 阅读全文
posted @ 2016-06-21 16:42 qscqesze 阅读(354) 评论(0) 推荐(0) 编辑
摘要:傻逼树模板 struct SBT{ const static int maxn = 1e5 + 15; int lft[maxn] , rht[maxn] , key[maxn] , s[maxn] , tot , root ; void init(){ tot = root = 0 ; } voi 阅读全文
posted @ 2016-06-14 07:47 qscqesze 阅读(378) 评论(1) 推荐(0) 编辑
摘要:Splay 模板 struct SplayTree{ const static int maxn = 1e5 + 15; int ch[maxn][2] , key[maxn] , s[maxn] , tot , root , fa[maxn]; void init( int x , int val 阅读全文
posted @ 2016-06-14 07:47 qscqesze 阅读(445) 评论(0) 推荐(1) 编辑
摘要:快速询问两个数的GCD 我觉得只有智障会卡这个玩意儿…… const int maxn = 1e6; const int Sqrt_N = 1e3; int pre[maxn + 1] , decomp[maxn + 1][3] , dp[Sqrt_N + 1][Sqrt_N + 1]; int A 阅读全文
posted @ 2016-06-14 07:46 qscqesze 阅读(405) 评论(0) 推荐(0) 编辑
摘要:队友扒的uwi的读入挂,非常强,再也不用担心java比C++慢了…… import java.util. ; import java.math. ; import java.io.ByteArrayInputStream; import java.io.IOException; import jav 阅读全文
posted @ 2016-05-30 08:51 qscqesze 阅读(743) 评论(0) 推荐(0) 编辑
摘要:F. Four Divisors 题目连接: http://www.codeforces.com/contest/665/problem/F Description If an integer a is divisible by another integer b, then b is called 阅读全文
posted @ 2016-04-22 22:53 qscqesze 阅读(1000) 评论(0) 推荐(1) 编辑
摘要:模板如下: 扩展版本: 求解a^k=b %p 求k,最小的k一定小于p,否则会重复,否则无解 gcd(a,p)=1时 设k=mi+v m=sqrt(p); i,v include include define MOD 76543 using namespace std; int hs[MOD], h 阅读全文
posted @ 2016-04-19 21:26 qscqesze 阅读(531) 评论(0) 推荐(0) 编辑
摘要:FFT,这份代码在51nod跑的非常快,赶紧扒下来! //FFT 大整数乘法 include include include include using namespace std; const int N = 500005; const double pi = acos( 1.0); char s 阅读全文
posted @ 2016-04-11 19:02 qscqesze 阅读(629) 评论(2) 推荐(2) 编辑
摘要:奇怪的数学公式系列: 快速幂: long long quickpow(long long m,long long n,long long k)//返回m^n%k { long long b = 1; while (n 0) { if (n & 1) b = (b m)%k; n = n 1 ; m 阅读全文
posted @ 2016-01-14 13:06 qscqesze 阅读(1605) 评论(0) 推荐(4) 编辑
摘要:代码: struct Bit { vector<int a; int sz; void init(int n) { sz=n; for(int i=1;i<=n+5;i++) a.push_back(0); } int lowbit(int x) { return x&( x); } int qu... 阅读全文
posted @ 2015-12-21 14:55 qscqesze 阅读(329) 评论(0) 推荐(1) 编辑
摘要:// Made by xiper// updata time : 2015 / 12 / 8// test status: √// 使用前调用初始化函数 init() 同时 root[0] = 0;struct Trie_Persistent{ const static int LetterS... 阅读全文
posted @ 2015-12-09 11:45 qscqesze 阅读(668) 评论(0) 推荐(1) 编辑
摘要:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef unsigne... 阅读全文
posted @ 2015-11-24 14:55 qscqesze 阅读(953) 评论(0) 推荐(0) 编辑
摘要:## fread读入挂 const int BUF=40000000; char Buf[BUF],*buf=Buf; const int OUT=20000000; char Out[OUT],*ou=Out;int Outn[30],Outcnt; inline void write(int x 阅读全文
posted @ 2015-10-24 20:07 qscqesze 阅读(1038) 评论(0) 推荐(0) 编辑
摘要://点和线段树都从1开始//边使用vectorvector G[maxn];int dfs_clock,que[maxn*2],num[maxn],iii[maxn],b[maxn],a[maxn],top[maxn],deep[maxn],fa[maxn],idx[maxn];//采用静态链表//... 阅读全文
posted @ 2015-10-02 21:10 qscqesze 阅读(399) 评论(0) 推荐(0) 编辑