07 2021 档案
摘要:Jennie 然后套上去就行了 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #d
阅读全文
摘要:Jennie 结合一下上一个题的思想,先确定一下这个最大公因数可以是谁--n的因数, 所以说肯定要对n的每一个因数的倍数下手,其中去除乘起来为n的哪个外,我们要注意一下剩下的倍数要跟他互质 ‘这不就和上个题一样了 #include<iostream> #include<cstdio> #includ
阅读全文
摘要:Jennie 素数不多,我们考虑素数就可以了 对于素数来说,能以他为gcd,那么肯定时它的倍数,且,那么我们先求出有多少个prime的倍数,然后取出两个互质的倍数,就是一个答案 这不就时的干的好
阅读全文
摘要:Jinsoo 用更相减损术写的 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define int long long using namespace std; long long a,b,c;
阅读全文
摘要:Jennie 似乎对于每一个不等式,都是有一个阈值k,那么分类讨论a的符号,也就是不等式的方向,因为输入的key的大小不超过,那么一些算出来的key可以知道肯定满足、不满足 然后呢,根据不等式的方向扔到两个树状数组,查询即可 #include<iostream> #include<cst
阅读全文
摘要:Archie 建反图,dfs #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; int n,m; int x,y; struct e{ int to; int
阅读全文
摘要:Jisoo tarjan求割边 对于一条,如果他是割边,那么v子树中一定有一个点s 然后改造一下搜索函数 #include<iostream> #include<cstdio> #include<algorithm> #include<stack> using
阅读全文
摘要:Jisoo 如果这玩意成不了二分图,肯定有环,而且还是肯定有一个三元环 如果一个点到两个点的距离那么这两个点之间的距离一定大于k 那么我们只要确定存不存在这样的三元组就可以了 怎么确定呢 画图可得,如果有三元环,那么这个三元环一定会存在一种包括两端点的情况 然后就显然我们要找直径,检查每一个
阅读全文
摘要:Jennie 每个单词只有两个字符,那么就在这两个字符之间连一条边。 最后n+1个字符,显然是所有单词只出现了一遍 这样我们的目标就是找一条欧拉路径就可以了 #include<iostream> #include<cstdio> #include<algorithm> using namespace
阅读全文
摘要:Rose 也是可以接受的对吧 化简式子得和 然后枚举的因子就可以了 #include<iostream> #include<cstdio> #include<cstring> #incl
阅读全文
摘要:Lisa 这个不如先简简单单看成n,然后可知,且不如令代入原式子,可知 那么a,b就是它的一对因子了 #include<iostream> #include<cstdio> #include<algorithm> #inc
阅读全文
摘要:Lisa 显然状态压缩 然后,对于一个点集S,我们很容易求出这个点集可以形成的任意图 这个很容易预处理出来 然后呢,对于这个直接求联通的方案书并不容易,但是,可以用总方案减去不连通的方案数。 不连通的方案视为两个点集,一个点集随便,另一个点集必须联通。 所以在预处理完了以后,我们首先要做的
阅读全文
摘要:jennie 树上dp求直径的模板 #include<iostream> #include<cstdio> #include<cstring> #include<vector> using namespace std; int n; vector<int> v[100001]; int x,y; i
阅读全文
摘要:P1908 逆序对 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 树状数组可以干这个事情 树桩数组维护一个下标啦 然后离散化一下,sort,unique,二分确定每一个数在新序列的下标 也就是第i个数大小的排名。 然后算一下有多少个数,拍在他前面且大小排名在它之前。 #inclu
阅读全文
摘要:blackpink yyds 这道题目还是很有意思的,叫什么最短路径生成树。 显然的一个做法就是用类似于prim的方法,维护一个已经和1联通的集合以及所有点到1的最短路 然后按照距离dis的距离进行枚举,每次从集合里找到可以在加进去之后令新点补全。 然后这个过程可以懒得维护,直接检查每一个点和他周围
阅读全文
摘要:Archie 树链刨分之后很显然就成了一条一条的链 那么用线段树维护一下就行了 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,m,r,pp; s
阅读全文
摘要:数据范围小地可怜 那就模拟退火 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int ans[50]; int son[50
阅读全文
摘要:Archie 练习一下树刨 只要记录一下到链顶的距离以及到父亲的距离就行了 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,m; struct e
阅读全文
摘要:Archie 本文为倍增做法 后缀数组题 后缀数组是啥,把所有的后缀排个序就是后缀数组了 显然的暴力做法就是全部sort一遍 这不白瞎 我们利用倍增的思想,显然可以把一个字符串分成两半进行比较就可以了 引用一下wiki的图片。 这里有两个数组 表示第i小的后缀的编号 而表示第
阅读全文
摘要:Archie 这只是一道橙题,为什么我要写呢,。 因为这个题可以用基数排序做 以下做法为基数排序+计数排序 计数排序 和桶排有所相似 首先,统计每个值的出现次数 然后呢,在值域范围内统计次数的前缀和 然后从后往前扫并统计 for(int i=m;i>=1;--i){ b[tot[3][a[i]%10
阅读全文
摘要:Archie 当年咋就不加ull呢 很简单,按照二进制位拆就行了 /* �Һܱ�Ǹ */ #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> #include<stack> #
阅读全文
摘要:Archie 线段树精简版 没有lazy,没有pushdown #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define int long long using namespace std; c
阅读全文
摘要:Archie 这是个什么东西呢 一看数据范围,肯定,带个都不太肯能,再一看体面,y似乎没大有用 移项,发现这是啥意思呢,就是说,x+y需要是偶数,x,y奇偶性相同,颜色相同,那么我们何不把这些东西扔到一块去 然后,每与每一对数推式子,发现对于有k个数的堆,他的贡
阅读全文
摘要:splay splay与他的解析 二叉搜索树 我们搞一棵树,保证左子树所有点的权值比父亲小,右子树所有点权值比父亲大 显然这个玩意可以快速查询一个数存不存在,排名啦啥的 插入的时候直接顺序造节点,删除的时候,断开重连是件很愚蠢的事情 应该把删除节点和他右子树最左边那个或者左子树最右边那个交换,销毁它
阅读全文
摘要:Archie 怎样用模拟退火搞序列 随机交换就可以了 dp检查 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> using namespace std; int n,m
阅读全文
摘要:Archie 这叫啥啊,区间异或+区间求和 我用动态开点写的 #include<iostream> #include<cstdio> #include<algorithm> #define ll long long using namespace std; int n,m; int x,y,z; i
阅读全文
摘要:Archie 显然是要求逆序对的,这东西当然可以用树状数组求就可以了 然后呢,对于每一个点i,它为后面的点的话,那的时候就会有贡献 扫就行了 #include<iostream> #include<cstdio> #include<algorithm> #define ll long lo
阅读全文
摘要:Archie 显然做法就是建反图,每个点都遍历一下,然后能过 然而有几个点死能卡常数,怎么办呢 干他 如果一头牛不能到达所有奶牛,它能到的所有牛都不行,同理,如果一头奶牛可以,它能到的所有牛都行 然而,这么干还是会被最后一个点干掉。 采用vector,对于每一个点的出边从小到大排序,因为最后枚举是
阅读全文
摘要:Archie 虽然只是个普通的普及 但我还要写一些 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n; string s[30]; bool cmp
阅读全文
摘要:Archie 区间加和单点查询 很简单的思路就是查询,就像线段树一样搞。一个tag #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std
阅读全文
摘要:Archie 出个好好的题卡什么输出格式 很简单的模拟退火 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<ctime> using namespac
阅读全文
摘要:Archie 很显然的换根dp #include<iostream> #include<cstdio> #include<cstring> using namespace std; int son[100001]; int dis[100001]; int n; int a,b; int head[
阅读全文
摘要:Archie 显然这玩意可以胡搞 怎么搞 模拟退火基本知识 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; double delat=0.993; double
阅读全文
摘要:Archie 拉格朗日插值法 知道了n个点的坐标,构造出一个n次多项式 然后求f(x) 公式 就行了 #include<iostream> #include<cstdio> #include<cstr
阅读全文
摘要:Archie 记忆化搜索就好 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int m; int x; int a[10005]; int n,k; int
阅读全文
摘要:Archie 还是很水的 注意一下边界 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,m; int d[10001]; int dp[10005
阅读全文
摘要:dpdpdp Archie 很显然,每一层之间有最优子结构 那么,怎么转移呢,既然两个方向,那就加一维从哪里走 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #define int long lon
阅读全文
摘要:Archie 一道比较显然的构造题 呸 显然1和0的数量都需要是偶数,不然必挂 显然开头和结尾必须相互匹配,不然也挂 然后用1把这里分成一小块一小块,每一块,如果有偶数个零,显然可行 奇数个零的块必然成双存在,同上处理 01分开构造 #include<iostream> #include<cstri
阅读全文
摘要:Archie 首先很显然的是,无论怎么选,这里肯定会有一条贯穿的横向和一条纵向的骨架 那么问题来了,剩下的呢 按照大小一个一个插,不要有环出现 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #def
阅读全文
摘要:P2736 [USACO3.4]“破锣摇滚”乐队 Raucous Rockers 死小的数据范围 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; int n,
阅读全文
摘要:[Archie]([P1006 NOIP2008 提高组] 传纸条 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)) 一步一步的走有点烦,何不走两步一次 #include<iostream> #include<cstdio> #include<algorithm> using na
阅读全文
摘要:Archie 很简单的小模拟 我们把每四位数和一个:作为一段进行处理 小小的特判 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; string s; int a[9]; int main(){
阅读全文
摘要:sczyyds sczyyds sczyyds I can't forget 你需要知道怎么求位数 #include<cmath> #include<cstdio> #include<iostream> #define ll long long using namespace std; ll n;
阅读全文
摘要:这里应该写什么 很显然,先把所有学生排序并且分组 然后,把两个组合并 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define int long long using namespace std
阅读全文
摘要:FOGGY 记忆化搜索 改变每一个叶子节点,它的影响是线性的往根节点走 也就是说,如果一个父节点在这条路径上改变了,并且这种改变会影响到根节点那么应该标记, 同理,没有影响的改变 也就是说,标记某个节点的改变的影响 那么怎么具体搞呢 对于每一种操作,单独分析 #include<
阅读全文