随笔分类 -  树状数组

摘要:适用于单个元素经常修改,反复求不同区间和的情况。 函数 求和:$sum(k)=C[n_1]+C[n_2]+…+C[n_m]$ $n_m=k, n_{i-1}=n_i-lowbit(n_i)$ $a[i]+….+a[j]=sum(j)-sum(i)$ 更新: $a[i]$更新,有且只有$C[n_1], 阅读全文
posted @ 2018-12-13 00:02 TobicYAL 阅读(198) 评论(0) 推荐(0)
摘要:题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某一个数加上x 2.求出某区间每一个数的和 输入输出格式 输入格式: 第一行包含两个整数N、M,分别表示该数列数字的个数和操作的总个数。 第二行包含N个用空格分隔的整数,其中第i个数字表示数列第i项的初始值。 接下来M行每行包含3个整数, 阅读全文
posted @ 2018-10-22 10:04 TobicYAL 阅读(184) 评论(0) 推荐(0)
摘要:描述 一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的。对于给定的一个序列(a1, a2, ..., aN),我们可以得到一些上升的子序列(ai1, ai2, ..., aiK),这里1 <= i1 < i2 < ... < iK <= N。比如,对于序列(1, 阅读全文
posted @ 2018-10-09 22:59 TobicYAL 阅读(840) 评论(0) 推荐(0)
摘要:描述 Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares 阅读全文
posted @ 2018-10-08 18:11 TobicYAL 阅读(241) 评论(0) 推荐(0)
摘要:描述 There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been car 阅读全文
posted @ 2018-10-08 18:02 TobicYAL 阅读(268) 评论(0) 推荐(0)