poj 3468 A Simple Problem with Integers 线段树,区间更新.

中科蓝讯蓝牙耳机SDK实战:从目录解析到消息处理框架 本文深入解析中科蓝讯蓝牙耳机SDK的目录结构与消息处理框架,提供从硬件驱动到蓝牙功能定制的实战指南。重点剖析SDK核心模块如消息队列机制、按键事件处理及电量报告优化,并分享二次开发中的调试技巧与避坑经验,助力开发者高效完成TWS耳机功能定制。 阅读详情

A Simple Problem with Integers,题目链接 ,click here

Description

You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.

Input

The first line contains two numbers N and Q. 1 ≤ N,Q ≤ 100000.
The second line contains N numbers, the initial values of A1, A2, … , AN. -1000000000 ≤ Ai ≤ 1000000000.
Each of the next Q lines represents an operation.
“C a b c” means adding c to each of Aa, Aa+1, … , Ab. -10000 ≤ c ≤ 10000.
“Q a b” means querying the sum of Aa, Aa+1, … , Ab.

Output

You need to answer all Q commands in order. One answer in a line.

Sample Input

10 5
1 2 3 4 5 6 7 8 9 10
Q 4 4
Q 1 10
Q 2 4
C 3 6 3
Q 2 4
Sample Output

4
55
9
15
Hint

The sums may exceed the range of 32-bit integers.
Source

POJ Monthly–2007.11.25, Yang Yi

一道很经典的线段树区间更新,上浮还有下浮,套模板就能过的.




#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
#define lson l,m,rt<<1       //左儿子;
#define rson m+1,r,rt<<1|1   //右儿子;
#define root 1,n,1           //建树的时候简便用的;
#define ll long long         //long long ;
const int N    =  100005;
ll sum[N<<2];   //建树数组;
ll add[N<<2];   //延迟标记,更新;

//上浮;
void pushup(int rt)
{
    sum[rt]=sum[rt<<1]+sum[rt<<1|1];
}
//下沉;
void pushdown(int rt,int m)
{
    if(add[rt])
    {
        add[rt<<1]  +=add[rt];
        add[rt<<1|1]+=add[rt];
        sum[rt<<1]  +=add[rt]*(m-(m>>1));
        sum[rt<<1|1]+=add[rt]*(m>>1);
        add[rt]=0;
    }
}

//建树;
void build(int l,int r,int rt)
{
    add[rt]=0;
    if(l==r)
    {
        scanf("%I64d",&sum[rt]);
        return ;
    }
    int m=(l+r)>>1;
    build(lson);
    build(rson);
    pushup(rt);//注意上浮;
}

//更新;
void update(int L,int R,int c,int l,int r,int rt)
{
    if(L<=l&&r<=R)
    {
        add[rt]+=c;
        sum[rt]+=(ll)c*(r-l+1);
        return;
    }
    pushdown(rt,r-l+1);//注意下沉;
    int m=(l+r)>>1;
//    if(L<=m) update(L,R,c,lson);
//    if(R>m)  update(L,R,c,rson);
//这里的判断用上边的还是用下边的都可以;
    if(R<=m)
            update(L,R,c,lson);
    else if(L>m)
        update(L,R,c,rson);
    else
    {
        update( L ,m,c,lson);
        update(m+1,R,c,rson);
    }
    pushup(rt);
}
ll query(int L,int R,int l,int r,int rt)
{
    if(L<=l&&r<=R)
        return sum[rt];
    pushdown(rt,r-l+1);
    int m=(l+r)>>1;
    ll ans=0;
    if(L<=m) ans+=query(L,R,lson);
    if(R>m)  ans+=query(L,R,rson);
    return ans;
}
int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    build(root);
    char op[5];
    while(q--)
    {
        int a,b,c;
        scanf("%s",op);
        if(op[0]=='Q')
        {
            scanf("%d%d",&a,&b);
            printf("%I64d\n",query(a,b,root));
        }
        else
        {
            scanf("%d%d%d",&a,&b,&c);
            update(a,b,c,root);
        }
    }
    return 0;
}

很简单的一道题,硬是让我写了一下午,写了两遍,对自己的智商感到深深的忧桑~!!
一个位运算”<<”让我写成”>>”,改了好久…好坑!!一直RE.QAQ

10、网络安全工具:Bettercap 与 Web 应用测试工具全解析 本文详细解析了网络安全工具Bettercap及其在中间人攻击和无线攻击中的应用,同时介绍了多种Web应用测试工具,如Amass、Cadaver、Dirb等,并探讨了工具的使用场景、流程、注意事项以及未来发展趋势,为网络安全测试提供了全面的指导。 阅读详情

相关推荐

html python mysql交互_干货!Python与MySQL数据库的交互实战

安装PyMySQL库如果你想要使用python操作MySQL数据库,就必须先要安装pymysql库,这个库的安装很简单,直接使用pip install pymysql;假如这种方式还是安装不上,就用如下链接找一个合适的安装包,进行安装,这个就不细说了。https://www.lfd.uci.edu/~gohlke/pythonlibs/使用Python连接MySQL数据库1)六个常用的连接参数参数...

weixin_31043555的博客 1566

POJ 3468 A Simple Problem with Integers【线段树区间更新入门题】

线段树区间更新入门题。区间更新用单点更新的方法去做必然会TLE,当要更新的区间正好是某个节点的区间的时候,我们就更新到此,不再继续往下更新,从而节省了时间,实现了次区间更新的高效性。 但后面更新的区间是上次更新区间的子区间的时候就要把之前保存在父节点的更新数据“下放”到对应的子区间,从而实现了操作的正确性。 对于线段树区间更新的描述网上有好多不错的博客,我就不用再去造轮子了。写法也有好多种,适合自己的才是最好的。 以下三篇代表了几种不同的写法。 此题参考博客:http://blog.csdn.net/w00

AC_Dreameng 1420

HarmonyOS开发第一步:Dev Eco Studio4.0保姆级安装配置指南(含Node.js环境)

本文提供HarmonyOS开发环境搭建的保姆级教程,重点详解Dev Eco Studio 4.0的安装与配置,并攻克Node.js环境与Ohpm包管理器的关键设置难点。通过清晰的步骤指引,帮助开发者从零开始,高效完成开发环境部署,顺利迈出鸿蒙应用开发的第一步。

lake5的博客 575

POJ 3468 A Simple Problem with Integers(线段树区间更新)

题目来源:http://poj.org/problem?id=3468 问题描述 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 142569   Accepted: 44...

da_kao_la的博客 274

用Multisim和74HC系列芯片,手把手教你搭建一个能“算数”的简易CPU模型

本文详细介绍了如何使用Multisim仿真软件和74HC系列芯片搭建一个简易CPU模型,重点解析了74HC194寄存器和74HC283加法器的核心功能与连接方法。通过分步图解和实战调试,帮助读者理解CPU工作原理,掌握数字电路设计的基本技能,适合计算机组成原理初学者和电子爱好者实践学习。

weixin_26843605的博客 146

TJA1445/TJA1465 CAN收发器硬件设计与软件配置实战指南

控制器局域网(CAN)总线是汽车电子和工业控制领域实现电子控制单元(ECU)间可靠通信的核心技术。其工作原理是将数字信号转换为差分信号进行抗干扰传输,技术价值在于构建稳定、高效的分布式实时控制系统。随着汽车电子架构向域集中式演进,对CAN总线的通信速率、网络复杂度和静态功耗提出了更高要求,这催生了支持CAN FD协议和智能电源管理的新一代高速CAN收发器。在车载网关、域控制器及工业网络节点等应用场景中,NXP的TJA1445和TJA1465系列收发器凭借其部分组网(Partial Networking)和选

weixin_29655587的博客 420

【POJ】3468 - A Simple Problem with Integers(线段树区间更新)

题目链接:点击打开链接 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 100877   Accepted: 31450 Case Time Limit: 2000MS Descrip

wyg1997 2319

【小程序】支付宝直付通解决方案

支付宝直付通是支付宝为小程序提供的一种支付解决方案,可以实现小程序中直接使用支付宝进行支付。以上是一个简单的支付宝直付通解决方案及相关代码示例。具体的使用还需要根据自己的业务需求进行定制化开发和调整。

qq_31532979的贺公子之数据科学与艺术博客,致力于科技向善,拥抱开源,要用技术的影响力来领导团队,而不是威权和职位! 1287

poj3468 A Simple Problem with Integers 线段树【区间更新】

题目链接在这里 题目描述: 有n个数m个操作,操作有两种: 1.Q x y 查询区间[x, y]的和 2.C x y z 区间[x, y]中的每个元素增加z 思路分析: 运用线段树维护点的信息,在区间更新的时候lazy思想在节点上mark一下。 代码如下: #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;...

Joel 240

十一、增强现实

那都是n年前的老版本了,新版本完全没有这个问题,我就是纠结这个问题,搭建若干环境,又是vmware虚拟机,又是msys2,又是anaconda,又是找机器,折腾了几天,结果通通不是。以一张实际卡片为锚点,通过笔记本的摄像头,在显示器上将一个计算机内的3d物体显示在卡片上,类似于电影上看到的那种全息投影技术;如果你是想在windows环境下开发linux运行程序,那么CygWin/gcc是你的不二之选。而如果你想开发的是windows运行程序,并且追求速度,那么二者相比而言,MinGW是更好的选择。

3190

Android/Linux驱动开发:使用dev_dbg进行设备驱动调试

在本文中,我们将介绍如何使用dev_dbg宏和相关的函数来进行设备驱动调试。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。的结构体指针,其中包含了我们定义的文件操作函数。的结构体指针,其中包含了我们定义的文件操作函数。在上面的示例中,我们首先通过调用。在上面的示例中,我们定义了。在上面的示例中,我们定义了。

ByteKnight的博客 378

POJ3468 A Simple Problem with Integers 线段树区间更新

POJ3468 A Simple Problem with Integers/*线段树区间更新 2000MS 4484K */ #include &lt;stdio.h&gt; #include &lt;string.h&gt; const int MAX=1e5+5; long long tree[MAX*4]; long long lazy[MAX*4];//延时数组 void read...

Qianyri的博客 247

S7-200 SMART PLC 数字量阀门控制功能块(FB)汇总

S7-200 SMART PLC功能块的各种写法可以查看专栏的其它文章,链接地址如下:S7-200 SMART PLC 子程序功能块(阀门控制)_RXXW_Dor的博客-CSDN博客_plc控制阀门开关程序由于S7-200 SMARTPLC的子程序种种功能、容量限制,有时想实现多次调用的子程序可能并不是太容易,这篇博客还是给出一些推荐写法,供大家参看。

RXXW_Dor的博客 4007

POJ[3468] A Simple Problem with Integers 【线段树区间更新】

Description You haveNintegers,A1,A2, ... ,AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is t...

醉酒、冰城外 159

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Poj3468 A Simple Problem with Integers 线段树、区间更新

Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is

Megumin的博客 353

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

poj 3468 A Simple Problem with Integers 线段树 区间更新求和

线段树第二天,下午由于做了多校的第一场virtual judge,所以直到晚上才有时间来搞这道题 除了早上做的那个区间染色的问题,这个问题应该也是个入门题,当然由于鄙人智商是硬伤,没太反应明白,查了解题报告,再加上自己的一些尝试,最终侥幸AC了,下面说说思路: 首先,更新区间的时候不可能更新区间里的每一个点,这样复杂度太高 因此,在update的时候,找到对应的区间之后,直接给该区间存储一个

renew 746

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ3468 A Simple Problem with Integers 线段树区间更新

A Simple Problem with Integers  线段树区间更新 You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number i

资深罚时选手 232

A Simple Problem with Integers(POJ-3468)线段树 区间更新+区间求和

ASimple Problem with Integers(POJ-3468)线段树 区间更新加区间求和题目大意 POJ-3468的原题链接 题目大意 有一个数组长度为N的数组,总共输入T组数据指令,当输入 Q 指令时,代表要将 下标在 a,b之间的元素求和,而当输入C指令时,要求要将下标在a,b之间的所有数组元素都加上c. #include <cstring> #include &l...

一只特立独行的猫的博客 228

poj3468 A Simple Problem with Integers 线段树区间更新,区间求和

传送门:poj3468 A Simple Problem with Integers题目大意输入:第一行输入两个数N和Q。N代表有多少个元素,Q代表进行多少次操作 第二行数输入n个数 表示对应的初始值 然后下面的Q行代表操作: C a b c把a到b区间的数增加c Q a b输出a到b区间的数量之和 输出:每当有Q操作输出a到b区间的数量之和解题思路如果总是WA的话,可以测试这个数据:10

woshinannan的专栏 601

poj 3468 A Simple Problem with Integers 线段树区间更新

点击打开链接题目链接 A Simple Problem with Integers Time Limit:5000MS Memory Limit:131072K Total Submissions:63565 Accepted:19546 Case Time Limit:2000MS ...

aodiyi6351的博客 139

POJ 3468 A Simple Problem with Integers(线段树区间更新+求和)

题目链接:http://poj.org/problem?id=3468 参考了胡浩大牛的代码模板: 区间更新+区间求和 #include #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define mid (l+r)>>1 #define LL long long using namespace std; const int ma

Learn as if you were to live forever 567

线段树 区间更新 区间查询 poj3468 A Simple Problem with Integers

相比较于单点更新和单点查询来说 区间更新多了一个pushdown函数 代码如下void pushdown(int root,int m){ if(add[root]){ add[root<<1] += add[root]; add[root<<1 | 1] += add[root]; sum[root>1)); sum[root>1); add[root] = 0; }

meixiuxiudd的博客 432

poj 3468 A Simple Problem with Integers(线段树区间更新)

题意:http://poj.org/problem?id=3468 这纯粹研究区间更新,区间查询,熟练掌握线段树的运用技能。相比,单点更新,多了add标志,adding, query操作时也多了对它的特殊操作pushdown。 #include #include using namespace std; #define LL long long const LL maxn=1e5+5;

theArcticOcean 689

POJ-3468 A Simple Problem with Integers 【线段树:区间更新】

POJ-3468 A Simple Problem with Integers 【线段树:区间更新】 题意:对于一串n长的数,进行m次操作,具体如下: 两种操作: 'Q’:询问 [ a,b ]区间的和值 'C’:[ a,b ]区间里面的每个数+x

SaySomething 325

poj3468 A Simple Problem with Integers 线段树区间更新

A Simple Problem with Integers You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interv...

cloudy_happy的博客 187

POJ 3468:A Simple Problem with Integers(线段树应用之:区间更新,区间查询)

POJ 3468:A Simple Problem with Integers(线段树应用之:区间更新,区间查询) Description You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given n...

serendipity的博客 371
上一篇: hdu 1754 I Hate It 线段树
下一篇: 线段树刷题指南(转载自网络)
落幕丶式
博客等级 码龄11年 2粉丝 45原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值