摘要: 差分数组是什么呢? 差分数组是前缀和的逆运算。 一般定义的差分数组是原数组相邻两个元素之间的差的数组,后面也有非一般的定义。 如一维原数组是a[i],则一阶差分数组是d[i] = a[i]-a[i-1],对一阶差分数组d[]求一遍前缀和就能得到原数组a[]; 一阶差分数组的一阶差分数组是二阶差分数组 阅读全文
posted @ 2017-10-29 18:13 Wisdom+.+ 阅读(886) 评论(0) 推荐(0) 编辑
摘要: 区间和模板: const int N=1e5+5; int c[N]; int n; int lowbit(int x) { return x&(-x); } int sum(int x) { int ret=0; while(x) { ret+=c[x]; x-=lowbit(x); } retu 阅读全文
posted @ 2017-10-29 13:54 Wisdom+.+ 阅读(424) 评论(0) 推荐(0) 编辑