题意:

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

#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. [Luogu] P4838 P哥破解密码

    题目背景 P哥是一个经常丢密码条的男孩子. 在ION 8102赛场上,P哥又弄丢了密码条,笔试满分的他当然知道这可是要扣5分作为惩罚的,于是他开始破解ION Xunil系统的密码. 题目描述 定义一个 ...

  2. 零基础入门学习Python(16)--序列!序列!

    前言 你可能发现了,小甲鱼把这个列表,元组,字符串放在一起讲是有道理的,它们有许多共同点: 都可以通过索引得到每一个元素 默认索引值总是从0开始 可以通过分片的方法得到一个范围内的元素的集合 有很多共 ...

  3. asp.net:Parser Error & HTTP 错误 500.21 - Internal Server Error

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABEcAAAF8CAIAAACiwUIQAAAgAElEQVR4nO2dyZHzOpZGaVEaADNkBB ...

  4. 集训第五周动态规划 J题 括号匹配

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

  5. 一种RC滤波电路的验证

    在做电源的时候,在开关管的D极经常是出现不想看到的尖峰脉冲.以CCFL推挽式缓冲电路为准,我与一个同学杨进行了相应的验证. 其中的出来的现象和反思如下: 1,加上电阻和电容串联的滤波的确能将尖峰脉冲消 ...

  6. C#上位机开发(三)—— 构建SerialAssistant雏形

    上一篇简单介绍了C#的一些基本知识,并成功的Hello,World,那么从这篇开始,我们来自己动手写一个串口助手: 1.构思功能 串口助手在单片机开发中经常被用来调试,最基本的功能就是接收功能和发送功 ...

  7. 全文搜索(A-2)-推荐算法

    一般来说推荐算法分为两类. 基于内容过滤的推荐: 基于协同过滤的推荐: 基于内容过滤的推荐,基于特征码描述项目. 协同过滤算法的设计基于一个假设,“和目标用户相似度高的用户,其感兴趣的物品目标用户也会 ...

  8. CodeForces - 425E Sereja and Sets 题解

    题目大意: 我们有一个集合 S,其中包含了 m 个不完全相同的区间[l1,r1],[l2,r2]…[lm,rm] (1≤li≤ri≤n,li,ri 都为整数). 定义 f(S)=k,表示集合 S 中能 ...

  9. [ C语言 ] 迷宫 迷宫生成器 [ 递归与搜索 ]

    [原创]转载请注明出处 [浙江大学 程序设计专题] [地图求解器] 本题目要求输入一个迷宫地图,输出从起点到终点的路线. 基本思路是从起点(Sx,Sy)每次枚举该格子上下左右四个方向,直到走到终点(T ...

  10. cdq分治入门--BZOJ3262: 陌上花开

    n<=100000个人,每个人三个属性Ai,Bi,Ci,一个人i的等级为Ai>=Aj,Bi>=Bj,Ci>=Cj的人数,求每个等级有多少人. 裸的三维偏序.按照常规思路,一维排 ...