https://codeforces.com/problemset/problem/407/C (自用,勿看) 手模一下找一找规律,可以发现,对于一个修改(l,r,k),相当于在[l,r]内各位分别加上[1,0,0,0,0,..]做k+1次前缀和得到的数组 比如(l=3,r=6,k=2),[1,0,0,..]做k+1=3次前缀和后为[1,3,6,10,15,..],因此这次修改相当于a[l]+=1,a[l+1]+=3,a[l+2]+=6,a[l+3]+=10 很容易想到k从大到小排序,用差分维护…
高阶差分板子题 const int N = 1e5+111; int a[N], n, m, k; int C[N][111], d[N][111]; signed main() { scanf("%d%d", &n, &m); REP(i,1,n) scanf("%d", a+i); REP(i,0,n+100) { C[i][0]=1; REP(j,1,100) C[i][j]=(C[i-1][j]+C[i-1][j-1])%P; } REP(i…
codeforces 407C Curious Array UPD: 我觉得这个做法比较好理解啊 参考题解:https://www.cnblogs.com/ChopsticksAN/p/4908377.html 1.杨辉三角可以由多维前缀和求得. 2."搭顺风车"的思想. 3.// 右端点减去的那个数可以用组合数学的方法思考. #include<bits/stdc++.h> using namespace std; #define fi first #define se s…
$ >Codeforces \space 408 E. Curious Array<$ 题目大意 : 有一个长度为 \(n\) 的序列 \(a\) ,\(m\) 次操作,每一次操作给出 \(l, r, k\) ,使得 \(i \in[l, r]\) 加上 \(i-l+k\choose k\) ,求 \(m\) 次操作后的序列 \(1 \leq n, m \leq 10^5, 0 \leq k \leq 100\) 解题思路 : 观察发现这个操作是加上 \(C_{k+i}^{k}\) 这样的东西…
Codeforces 601B. Lipshitz Sequence 题意:,q个询问,每次询问给出l,r,求a数组[l,r]中所有子区间的L值的和. 思路:首先要观察到,斜率最大值只会出现在相邻两点上,因此可以处理出d数组,d[i]=a[i]-a[i-1].则问题转化为求d数组在指定区间内,所有子区间的最大值的和.枚举子区间的复杂度是平方级别,显然是不能接受的,所以可以用单调栈预处理出每个d[i]可以成为最大值的最大区间(形象地说,也就是d[i]为最大值的域可以延伸到左.右各多远),用l,r数…
Greg and Array CodeForces 296C 差分数组 题意 是说有n个数,m种操作,这m种操作就是让一段区间内的数增加或则减少,然后有k种控制,这k种控制是说让m种操作中的一段区域内的操作来实际进行,问进行完k种控制后,这n个数变成了啥. 解题思路 我开始使用了最简单的差分,就是把m种操作存到结构体数组中,然后在读取k中控制时,按照要求执行之前结构体数组中的一段区间内的操作,但是这样超时了.后来一想,如果直接知道m种操作每种操作的次数不就行了,于是我们需要两个数组,一个是用来记…
You've got an array consisting of n integers: a[1], a[2], ..., a[n]. Moreover, there are m queries, each query can be described by three integers li, ri, ki. Query li, ri, ki means that we should add  to each element a[j], where li ≤ j ≤ ri. Record  …
A. Robot Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U'…
D. Petya and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has an array aa consisting of nn integers. He has learned partial sums recently, and now he can calculate the sum o…
A. Infinite Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the…