![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树状数组
陈一Kristian
这个作者很懒,什么都没留下…
展开
-
树状数组
转:http://blog.csdn.net/int64ago/article/details/7429868 树状数组是做什么的 平常我们会遇到一些对数组进行维护查询的操作,比较常见的如,修改某点的值、求某个区间的和,而这两种恰恰是树状数组的强项!当然,数据规模不大的时候,对于修改某点的值是非常容易的,复杂度是O(1),但是对于求一个区间的和就要扫一遍了,复杂度是O(N),如果实时的对...转载 2018-10-06 17:51:21 · 170 阅读 · 0 评论 -
hdu1556 Color the ball树状数组
Problem Description N个气球排成一排,从左到右依次编号为1,2,3…N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input 每个测试实例第一行为一个整数N,(N <= 100000)....原创 2019-04-24 22:42:28 · 226 阅读 · 0 评论 -
paper plane fly away
链接:https://ac.nowcoder.com/acm/contest/903/E 来源:牛客网 There are n boys, indexed from 1 to n, and n girls indexed from n+1 to 2n. One day, they have a party together. The girls are seated in the first ro...原创 2019-06-06 14:06:16 · 478 阅读 · 5 评论 -
树状数组
树状数组说白了就是维护前缀和,只不过支持区间查询和区间修改,还有单点查询等等 java模板 import java.util.Arrays; public class seven { static int[] numbers = {1,2,3,4,5,6,7,8,9}; static int [] c; public static void main(String[] a...原创 2019-06-16 15:10:19 · 160 阅读 · 0 评论 -
hdu1541
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 刚开始知道了先按列排序再按行排序,一直没明白输出是怎么回事,可以联想到是左下角的所有的星的个数 注意题目上的描述: There can be only one star at one point of the plane. Stars are listed in ascending order ...原创 2019-07-03 12:07:53 · 227 阅读 · 0 评论