题意:

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

#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. python 1-1模块介绍和使用

    1. 什么是模块 1.1 模块就是一系列功能的集合体 1.1.1 模块有三种来源 1.内置的模块 2.第三方的模块 3.自定义模块 1.1.2 模块的格式: 1.使用Python编写的.py文件 2. ...

  2. 18Spring后置通知

    Spring后置通知,和前置通知类似,直接看代码: package com.cn.spring.aop.impl; //加减乘除的接口类 public interface ArithmeticCalc ...

  3. scrapy爬取简书整站文章

    在这里我们使用CrawlSpider爬虫模板, 通过其过滤规则进行抓取, 并将抓取后的结果存入mysql中,下面直接上代码: jianshu_spider.py # -*- coding: utf-8 ...

  4. JqueryValidate 修改 为根据ID验证

    <!--修改validate根据ID验证 --> <script type="text/javascript"> if ($.validator) { $. ...

  5. 集训第四周(高效算法设计)I题 (贪心)

    Description Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshe ...

  6. java生成6位随机数字

    //生成6位随机数字 System.out.println((int)((Math.random()*9+1)*100000)); //生成5位随机数字 System.out.println((int ...

  7. codeforces 363B

    #include<stdio.h> #include<string.h> #define inf 999999999 #define N 151000 int a[N],c[N ...

  8. 建造高塔(codevs 1689)

    题目描述 Description n有n种石块,石块能无限供应.每种石块都是长方体,其中第i种石块的长.宽.高分别为li.wi.hi.石块可以旋转,使得其中两维成为长度和宽度,第三维成为高度.如果要把 ...

  9. abs 暴力

    Given a number x, ask positive integer y≥2y≥2, that satisfy the following conditions: 1. The absolut ...

  10. reader dc

    https://get.adobe.com/cn/reader/otherversions/