题目链接:http://acm.uestc.edu.cn/#/problem/show/1344 区间加等差数列本质上就是区间修改区间查询,本来想用线段树做,结果这个题就是卡空间和时间……不得已学了区间修改区间查询的树状数组. #include<bits/stdc++.h> using namespace std; ; +; int a[maxn]; int N; int tree[maxn]; int tree2[maxn]; int lowbit(int x) { return x&…
传送门 解题思路 区间加等差数列+单点询问,用差分+线段树解决,线段树里维护的就是差分数组,区间加等差数列相当于在差分序列中l位置处+首项的值,r+1位置处-末项的值,中间加公差的值,然后单点询问就相当于在差分数列中求前缀和. #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; ; typedef long long LL;…