题意:

线段树的单点修改,区间查询

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<1|1
#define All 1,N,1
#define read freopen("in.txt", "r", stdin)
#define N 200010
const ll INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod = ;
int num[N<<],n,q;
void pushup(int rt){
num[rt]=num[rt<<]+num[rt<<|];
}
void build(int l,int r,int rt){
if(l==r){
scanf("%d",&num[rt]);
return;
}
int m=(l+r)>>;
build(lson);
build(rson);
pushup(rt);
}
void update(int p,int b,int l,int r,int rt){
if(l==r){
num[rt]=b;
return;
}
int m=(l+r)>>;
if(p<=m)update(p,b,lson);
else update(p,b,rson);
pushup(rt);
}
int query(int L,int R,int l,int r,int rt){
if(L<=l&&R>=r){
return num[rt];
}
int m=(l+r)>>;
int sum=;
if(L<=m)sum+=query(L,R,lson);
if(R>m)sum+=query(L,R,rson);
pushup(rt);
return sum;
}
int main()
{
char s[];
int a,b,cas=;
while(~scanf("%d",&n)&&n){
cas++;
if(cas!=)printf("\n");
build(,n,);
printf("Case %d:\n",cas);
while(~scanf("%s",s)){
if(s[]=='E')
break;
else if(s[]=='M'){
scanf("%d%d",&a,&b);
printf("%d\n",query(a,b,,n,));
}
else if(s[]=='S'){
scanf("%d%d",&a,&b);
update(a,b,,n,);
}
}
}
return ;
}

Potentiometers的更多相关文章

  1. UVALive 2191 Potentiometers (树状数组)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  2. LA 2191 - Potentiometers

    看题传送门 Fenwick树的应用~~~ #include <cstdio> #include <cstring> #include<algorithm> usin ...

  3. VSim [a Racing-simulator by Vell001]

    VSim [a racing-simulator by vell001] This is my first project about Racing. I am a Chinese with bad ...

  4. PID控制器(比例-积分-微分控制器)- V

    Linear Actuator - PID Control Introduction This application guide is designed to explain the basics ...

  5. PID控制器(比例-积分-微分控制器)- IV

    调节/测量放大电路电路图:PID控制电路图 如图是PlD控制电路,即比例(P).积分(I).微分(D)控制电路. A1构成的比例电路与环路增益有关,调节RP1,可使反相器的增益在0·5一∞范围内变化; ...

  6. PID DC/DC Converter Controller Using a PICmicro Microcontroller

    http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011794 ...

  7. Digital Adjustment of DC-DC Converter Output Voltage in Portable Applications

    http://pdfserv.maximintegrated.com/en/an/AN818.pdf http://www.maximintegrated.com/app-notes/index.mv ...

  8. CMOS DACs act as digitally controlled voltage dividers

    Digital potentiometers, such as Analog Devices’ AD5160, make excellent digitally controlled voltage ...

  9. ADC for programmable logic uses one capacitor

    Many electronic devices require user input for setting the application properties. Typical input dev ...

随机推荐

  1. LNMP环境搭建网站

    系统:Centos7.4 一台服务器安装nginx.php.mysql 原理不是很懂,但实测如下两种环境下都能成功,这里做下记录: 1.一个干净的系统,从0开始完成所有步骤,完成LNMP搭建 2.已经 ...

  2. 【Mysql数据库】学习笔记

    一.数据库的创建 create database database_name  DEFAULT CHARACTER SET utf8; //创建一个数据库 drop database database ...

  3. assert.doesNotThrow()

    assert.doesNotThrow(block[, error][, message]) 断言 block 函数不会抛出错误.查阅 assert.throws() 了解更多详情. 当调用 asse ...

  4. matplotlib的使用--折线图--入门

    目录 matplotlib应用介绍 一天天气变化图 两小时随机温度图 中文显示问题 个人交往统计图 多人交往统计图 总结 介绍: 举个例子(一天天气变化图): 假设一天中每隔两个小时(range(2, ...

  5. pdf & watermark & puppeteer

    pdf & watermark & puppeteer background image https://en.wikipedia.org/wiki/Watermark pdf &am ...

  6. CRT(secureCRT)中文显示研究&Linux中文字符显示

    关于secureCRT设置编码: 基本上只需要设置crt字符编码与远程服务器一致就可以了.要注意的是,有时设置完之后要重启secureCRT, 不然不会生效.

  7. FTPUtil工具类

    package com.xxx.common.util; import java.io.File; import java.io.FileOutputStream; import java.io.IO ...

  8. echarts模拟highcharts实现折线图的虚实转换

    多的不说直接上代码: <html><html lang="en"><head> <meta charset="utf-8&quo ...

  9. Ubuntu 16.04安装Ubuntu After Install工具实现常用软件批量安装

    这个软件集成了常用且好用的软件,且只需要选择需要的软件之后自动安装好,不需要额外设置. 安装: sudo add-apt-repository ppa:thefanclub/ubuntu-after- ...

  10. u盘--软驱

    https://item.taobao.com/item.htm?spm=a230r.1.14.26.XUgxcR&id=12352589458&ns=1&abbucket=5 ...