Codeforces 718C solution】的更多相关文章

C. Sasha and Array   time limit per test :  5 seconds memory limit per test :  256 megabytes Description Sasha has an array of integers a1, a2, ..., an. You have to perform m queries. There might be queries of two types: 1 l r x — increase all intege…
线段树. 线段树维护区间矩阵和,操作都是最简单的线段树.$lazy$标记不要记录乘了几次,直接记录乘了几次之后的矩阵就可以了,不然每次下传的时候再算一遍时间复杂度会提高. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include…
Point 1. 区间乘以一个数/矩阵的幂时,不要用指数相加的方法. 而要用直接维护mulv[x]表示区间要乘多少. 不然的话,空加一个logn 2. 要点在于,冲突的点连边,形成二分图,对于在同一个联通块的点,必然是左侧的所有点和右侧的所有点互换 因为,只要换了一个点,那么和其相连的点必然要换,以此类推得此结论. 3. 再进行极角排序时,一定要把最靠右下的点作为root,不然的话,因为其他的店可能围绕root构成一个环,按照应用叉积判断左右 进而排序的方法,没有应该位于序列第一个位置的点,排序…
题意: 维护一个序列,支持两种操作:1.区间[l,r]的权值+x2.询问区间[l,r]的函数和,即∑fib(x)这里的函数即斐波那契函数数据范围:1≤n,q≤105 思路:一般求斐波那契函数的方法可以考虑矩阵乘法,这里也是这样的.我们不用线段树维护权值,我们用线段树维护线段树维护区间矩阵和.有一个矩阵乘法的性质:A*B+A*C=A*(B+C)在求斐波那契数列中,是A*F,A是变换矩阵,F是列矩阵那么我们用线段树的lazy标记维护A矩阵,然后用sum维护F矩阵之后在线段树上,就变成了区间更新乘以x…
传送门 解题思路: 这道题给了我们一个崭新的角度来看线段树. 我们常常使用的线段树是维护区间的函数的. 这里呢,提示我们线段树其实还可以维护递推. 美好的矩阵递推性质支持了这一功能. 或者说,对于递推项求和,可以使用线段树维护矩阵. 区间向前递推可以用懒惰标记记录递推矩阵. 区间的查询可以是子节点矩阵和. 这其实也是满足分配率的. 最后pushup,pushdown搞一搞就好了. 代码(闲来无事卡常码风突变): #include<cstdio> #include<cstring>…
拖了一周才完成的题解,抛出一个可爱的表情 (っ'-')╮ =͟͟͞͞❤️.对我来说E.F比较难,都是线段树的题,有点久没写了. A - Infinite Sequence CodeForces - 675A 公差为c,首项为a的等差数列是否有一项等于b. 注意c为0的情况. #include<cstdio> long long a,b,c; int main() { scanf("%lld%lld%lld",&a,&b,&c); if(c==0&am…
题目链接:http://codeforces.com/contest/742/problem/B B. Arpa's obvious problem and Mehrdad's terrible solution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are some beautiful girls in…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output There are some beautiful girls in Arpa's land as mentioned before. Once Arpa came up with an obvious problem: Given an array and a number x, coun…
B. Arpa’s obvious problem and Mehrdad’s terrible solution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came u…
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位算贡献,一位数的贡献直接算即可 n=int(input()) ans=0 while (n>=10): tmp=n%10 tmp=10-tmp ans+=tmp n+=tmp while (n>0) and (n%10==0): n//=10 ans+=9 print(ans) B. Long N…