摘要:
https://www.luogu.org/problem/P3384 如题,已知一棵包含N个结点的树(连通且无环),每个节点上包含一个数值,需要支持以下操作: 操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z 操作2: 格式: 2 x y 表示求树从x到y结点最 阅读全文
摘要:
不会,先抄抄看。 来自oiwiki 我们先给出一些定义: fa 表示节点 在树上的父亲。 dep 表示节点 在树上的深度。 siz 表示节点 的子树的节点个数。 son 表示节点 的 重儿子 。 top 表示节点 所在 重链 的顶部节点(深度最小)。 tid 表示节点 的 时间戳 ,也是其在线段树中 阅读全文
摘要:
来自叉姐 cpp struct CenterTree { int n; int ans; int siz; int son[maxn]; void dfs(int u, int pa) { son[u] = 1; int res = 0; for (int i = head[u]; ~i; i = 阅读全文
摘要:
https://scut.online/p/31 还是不知道为什么RE了。的确非常玄学。 重构之后就没问题了。果然写的越复杂,分的情况越乱就越容易找不到bug。 cpp include using namespace std; typedef long long ll; int cnt[15]; i 阅读全文
摘要:
https://scut.online/p/37 一开始想到要根号分块预处理,但是不太懂具体怎么写。想不到如此暴力。 cpp include using namespace std; typedef long long ll; const int MAXN = 300000; //预留长出来的600 阅读全文
摘要:
https://scut.online/p/142 但是洲阁筛打表还是超时了,打的表不够长吧,在51nod上面要跑5s。要是快10倍得要密1000倍,根本打不出来(时间意义)。 暴力check要找的质数是不是要的那个。 cpp include typedef long long ll; using 阅读全文
摘要:
原来历史上1582年10月4日的下一天是1582年10月15日; cpp include using namespace std; typedef long long ll; struct Date { int y, m, d; Date(int y=0,int m=0,int d=0):y(y), 阅读全文
摘要:
https://scut.online/p/11 T了好多次,还想用mutimap暴力分解每个数的质因数。后来记录每个数的最小质因子过了。 cpp include using namespace std; typedef long long ll; int n, m, MOD; const int 阅读全文