Potentiometers
题意:
线段树的单点修改,区间查询
#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的更多相关文章
- UVALive 2191 Potentiometers (树状数组)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- LA 2191 - Potentiometers
看题传送门 Fenwick树的应用~~~ #include <cstdio> #include <cstring> #include<algorithm> usin ...
- 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 ...
- PID控制器(比例-积分-微分控制器)- V
Linear Actuator - PID Control Introduction This application guide is designed to explain the basics ...
- PID控制器(比例-积分-微分控制器)- IV
调节/测量放大电路电路图:PID控制电路图 如图是PlD控制电路,即比例(P).积分(I).微分(D)控制电路. A1构成的比例电路与环路增益有关,调节RP1,可使反相器的增益在0·5一∞范围内变化; ...
- PID DC/DC Converter Controller Using a PICmicro Microcontroller
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011794 ...
- 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 ...
- CMOS DACs act as digitally controlled voltage dividers
Digital potentiometers, such as Analog Devices’ AD5160, make excellent digitally controlled voltage ...
- ADC for programmable logic uses one capacitor
Many electronic devices require user input for setting the application properties. Typical input dev ...
随机推荐
- sed输出指定行
and line ,8p to line ,8p -e 20p - and line -n:取消默认输出.注意:sed命令会默认把输入行打印到屏幕上,所以如果想精准的控制输出,就需要-n. -e:进行 ...
- Android Studio + Genymotion模拟器安装与配置
一.Android studio 下载与安装 https://developer.android.google.cn/studio/index.html 进入谷歌官方链接下载Android studi ...
- Python中关于使用正则表达式相关的部分笔记
一点点自己记的笔记,如果各位朋友看不懂,可以在评论区留言,会尽可能快的回复. 所有的知识点全部贴在代码上了,注释也写了. 建议大伙把代码拷到自己的机器上,运行,查看结果,然后,结合注释,再自己稍稍理解 ...
- 百度地图离线API 2.0(含示例,可完全断网访问)
由于公司需求,自己修改的离线地图API.该压缩包具有如下功能:1.支持使用google地图瓦片(不建议使用,效率不高,缩放级别较高时拖动有些卡顿,建议注释该代码块:overlayTileLayer.g ...
- C51 使用端口 个人笔记
使用整个端口的8个引脚: 八个引脚,需要8位2进制,2位十六进制 #define P0 led led = 0x3f; //led = ~0x3f; 使用某个端口的某一个引脚 sbit led = P ...
- Java面向对象学习-----类的成员变量
类的成员变量: 猜数字游戏:一个类A有一个成员变量v,通过随机产生一个100内的整数给v赋值.定义一个方法,对A类的成员变量v进行猜. 没有猜对的情况下提示如果大了则提示大了,小了则提示小了,并且 ...
- english & utils & tools
english & utils & tools https://openlanguage.com/ https://www.grammarly.com/blog/email-writi ...
- Linux下汇编语言学习笔记23 ---
这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...
- [bzoj2982]combination_卢卡斯
Combination bzoj-2982 题目大意:求$C_n^m/%10007$. 注释:$1\le n,m\le 2\cdot 10^9$. 想法:裸卢卡斯定理. 先处理出$mod$数之内的阶乘 ...
- c++ stl 使用汇总(string,vector,map,set)
1.string 1>substr(),截取字串的方法.返回一个从指定位置开始,并具有指定长度的子字符串.参数 start(必选),所需的子字符串的起始位置.字符串中第一个字符的索引为 0.le ...