随笔分类 -  _模板

摘要:点 $ (i,j) $ 会看不见当有 $ k|i $ 且 $ k|j$ 时。 然后就成了求欧拉函数了。 cpp include include include using namespace std; int n, phi[40005], pri[40005], cnt; bool isp[4000 阅读全文
posted @ 2017-12-19 20:08 poorpool 阅读(146) 评论(0) 推荐(0)
摘要:hdu1787,直接求欧拉函数 poj2478,欧拉函数递推,证明可以看 "这里" 或者是算法竞赛进阶指南 $n \log n$ 筛 cpp include include include using namespace std; int n; long long phi[1000005]; voi 阅读全文
posted @ 2017-12-19 19:15 poorpool 阅读(171) 评论(0) 推荐(0)
摘要:如果prime[i]是k的因子,那么【k \ (在prime[i]以后的质数)】等于【prime[i]\ (k/prime[i])\ (这个质数)】,一定被筛过了,所以这里可以break。 cpp include include include using namespace std; bool i 阅读全文
posted @ 2017-12-15 21:35 poorpool 阅读(164) 评论(0) 推荐(0)
摘要:先是维修数列 题解看 "这里" ,但是我写的跑得很慢 下面是poj的,稍加改动即可ac洛谷。 如果想看题意分析及讲解请看 "这里" ,讲得很好,一下就让我明白splay维护区间了。 splay的价值在于维护区间,如果只是维护点的话完全可以用treap等平衡树代替 阅读全文
posted @ 2017-12-15 17:05 poorpool 阅读(231) 评论(3) 推荐(0)
摘要:悬线法 cpp include include include using namespace std; int n, m, ans=0, h[1005][1005], l[1005][1005], r[1005][1005]; bool a[1005][1005]; char s[15]; int 阅读全文
posted @ 2017-12-13 18:41 poorpool 阅读(127) 评论(0) 推荐(0)
摘要:建议看看 "王知昆dalao的论文" ,讲得很好 cpp include include include include using namespace std; int l, w, n, ans=0, sh, xi, ma; struct Node{ int x, y; }nd[5105]; bo 阅读全文
posted @ 2017-12-13 10:48 poorpool 阅读(139) 评论(0) 推荐(0)
摘要:```cpp include include include using namespace std; int n, x; double a[55][55]; const double eps=1e 7; void gauss(){ for(int i=1; ia[maxi][i]) maxi = 阅读全文
posted @ 2017-12-12 20:17 poorpool 阅读(212) 评论(0) 推荐(0)
摘要:upd:现在推荐使用一个长度为 $n$ 的一维向量。若状态矩阵 $F$ 对下一时间的状态矩阵 $F'$ 有影响,则 $F'=FA$ 中的 转移矩阵 $A$ 的赋值方法是: 若状态矩阵中的第 $x$ 个数对下一单位时间的状态矩阵的第 $y$ 个数有影响,则将转移矩阵的第 $x$ 行第 $y$ 列赋值为 阅读全文
posted @ 2017-12-11 18:30 poorpool 阅读(168) 评论(0) 推荐(0)
摘要:2 SAT裸题 如果选u则必选v', 如果选v则必选u',连边即可。 cpp include include include using namespace std; struct Edge{ int too, nxt; }edge[40005]; int n, m, uu, vv, hea[160 阅读全文
posted @ 2017-12-08 15:45 poorpool 阅读(127) 评论(0) 推荐(0)
摘要:纪念一下我一晚上写了八遍AC自动机 这是加强版的: cpp include include include include using namespace std; int n, cnt[155], mp[155], len, maxn; char a[155][75], b[1000005]; q 阅读全文
posted @ 2017-12-05 21:38 poorpool 阅读(217) 评论(2) 推荐(0)
摘要:treap做法,参考 "hzwer的博客" splay做法,参照 "zyf2000" ,但是一般我们用splay都是维护区间的 阅读全文
posted @ 2017-12-04 18:52 poorpool 阅读(198) 评论(0) 推荐(0)
摘要:模板题 cpp include include using namespace std; struct Edge{ int too, nxt; }edge[200005]; int n, m, dfn[100005], loo[100005], ind, uu, vv, cnt, hea[10000 阅读全文
posted @ 2017-12-04 10:51 poorpool 阅读(209) 评论(0) 推荐(0)
摘要:K短路裸题。 阅读全文
posted @ 2017-12-03 20:28 poorpool 阅读(163) 评论(0) 推荐(0)
摘要:```cpp include include include include using namespace std; typedef unsigned long long ull; struct Node{ ull val1, val2; }node[10005]; char a[1505]; i 阅读全文
posted @ 2017-12-03 18:33 poorpool 阅读(150) 评论(0) 推荐(0)
摘要:注意:如果是这么个写法,堆数组要开成n+m的。 为什么呢?设想一下从1到2有m条长度递减的路,这岂不是要入队m次…… cpp include include include include using namespace std; struct Edge{ int too, nxt, val; }e 阅读全文
posted @ 2017-12-02 11:37 poorpool 阅读(180) 评论(0) 推荐(0)
摘要:```cpp include include include include using namespace std; int n, m, s, dis[10005], din, uu, vv, ww, hea[10005], cnt; bool vis[10005]; struct Node{ i 阅读全文
posted @ 2017-12-01 21:49 poorpool 阅读(191) 评论(0) 推荐(0)
摘要:模板题 cpp include include include using namespace std; int l1=1, r1, l2=1, r2, q1[1000005], q2[1000005], a[1000005], n, k; int ans1[1000005], ans2[10000 阅读全文
posted @ 2017-11-30 19:38 poorpool 阅读(120) 评论(0) 推荐(0)
摘要:模板题 cpp include include include using namespace std; struct Node{ int cnt, son[29]; bool hav; Node(){ cnt = hav = 0; } }trie[500005]; int c, n, m, len 阅读全文
posted @ 2017-11-29 20:14 poorpool 阅读(146) 评论(0) 推荐(0)
摘要:```cpp #include #include #include using namespace std; int nxt[1000005], len; char a[1000005]; void mknxt(){ int i=0, j; nxt[0] = j = -1; while(i0) i += k + 1; else j += k + 1; if(i==j) j+... 阅读全文
posted @ 2017-11-27 21:02 poorpool 阅读(136) 评论(0) 推荐(0)
摘要:nxt数组下标从1开始而a,b数组下标从0开始。 cpp include include include using namespace std; int lena, lenb, nxt[1000005]; char a[1000005], b[1000005]; void mknxt(){ int 阅读全文
posted @ 2017-11-27 20:37 poorpool 阅读(158) 评论(0) 推荐(0)