01 2021 档案

摘要:题意:给你n个数,q次询问,问你能否具有满足和为s的序列,再求其有多少种和时需要使用m i d = m a x + m i n > > 1 来寻找有多少种和。 思路:手动模拟一下有点像线段树建树的过程,那就按照线段树来写,把线段树建树的过程改动一下,求出所有可能的序列的和,然后标记 ,询问的时候看看 阅读全文
posted @ 2021-01-25 13:02 Swelsh-corgi 阅读(61) 评论(0) 推荐(0)
摘要:首先知道公式: 1、gcd(a1,a2,a3,a4……)=gcd(a1,gcd(a2,a3,a4……))2、gcd(a1,a2) = gcd(a1 , a2-a1) 推一下结论最后预处理一下 tp = gcd (a2 ​− a1​, ... , an ​− an−1​), 最后输出 gcd(a1​ 阅读全文
posted @ 2021-01-21 22:23 Swelsh-corgi 阅读(86) 评论(0) 推荐(0)
摘要:题意:有一个长度为n,只包含+ 和 -的字符串,+表示+1,-表示-1,x初始为0,有q次询问,每次询问输入一个区间表示该区间的符号忽略,问执行剩下的符号过程中出现几个不同的数 思路:线段树求区间最值,首先让 a[1]=0 ,然后利用 a数组进行构造线段树。这样就可以不用分类讨论了,只需要把在输入查 阅读全文
posted @ 2021-01-19 21:43 Swelsh-corgi 阅读(83) 评论(0) 推荐(1)
摘要:思路:分一下奇偶,然后记忆化搜索(第一次写记忆化,卡了半天。。。) #include<bits/stdc++.h> using namespace std; const int N=1e5+10; typedef long long ll; map<ll,ll> f; ll x,y; ll solv 阅读全文
posted @ 2021-01-14 22:25 Swelsh-corgi 阅读(105) 评论(0) 推荐(0)
摘要:思路:如果是奇数数个商店,排序后选中间的那个为货仓位置。如果是偶数个,排序后选取 n / 2或者 n / 2 + 1位置的商店。 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int main() { int n; 阅读全文
posted @ 2021-01-12 17:02 Swelsh-corgi 阅读(66) 评论(0) 推荐(0)
摘要:题意:求连通块内点的个数 思路:BFS 跑一遍,看看能到达那些点,记录下来,然后统计一下 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int vis[25][25]; int dis[4][2]= {-1,0,1, 阅读全文
posted @ 2021-01-12 16:55 Swelsh-corgi 阅读(93) 评论(0) 推荐(0)