#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define ms(arr,a) memset(arr,a,sizeof arr)
#define debug(x) cout<<"< "#x" = "<<x<<" >"<<endl
const int maxF=1e5+5;
int n,q;
long long s[maxF],ss[maxF];
inline lowbit(int x)
{
return x&(-x);
}
void adds(int i,long long k)
{
while(i<=n)
{
s[i]+=k;
i+=lowbit(i);
}
}
void addss(int i,long long k)
{
while(i<=n)
{
ss[i]+=k;
i+=lowbit(i);
}
}
long long sums(int i)
{
long long ret=0;
while(i)
{
ret+=s[i];
i-=lowbit(i);
}
return ret;
}
long long sumss(int i)
{
long long ret=0;
while(i)
{
ret+=ss[i];
i-=lowbit(i);
}
return ret;
}
int main()
{
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
while(~scanf("%d%d",&n,&q))
{
long long tmp;
for(int i=1;i<=n;++i)
{
scanf("%lld",&tmp);
adds(i,tmp);addss(i,tmp*i);
}
int a,b,c;
for(int i=1;i<=q;++i)
{
scanf("%d%d%d",&a,&b,&c);
if(a==1)
{
printf("%lld\n",1LL*(c+1)*(sums(c)-sums(b-1))-sumss(c)+sumss(b-1));
}
else{
long long tmp=sums(b)-sums(b-1);
adds(b,1LL*c-tmp);addss(b,1LL*b*c-tmp*b);
}
}
}
//freopen("CON","w",stdout);
//system("start Output.txt");
}

徐州H的更多相关文章

  1. 2018网络预选赛 徐州H 线段树+树状数组

    设读入的数组是a,树状数组用来维护a数组区间和sum,线段树用来维护一个另一个数组ssum的区间和,区间每个点a[i]*(n-i+1),那么l-r的答案是l-r的ssum-(n-r)*(sum[r]- ...

  2. 2018icpc 徐州h题

    题目大意: https://codeforces.com/gym/102012/problem/H?csrf_token=c9d0191a64a241166d54a565b1615125 区间[l , ...

  3. 计蒜客 1460.Ryuji doesn't want to study-树状数组 or 线段树 (ACM-ICPC 2018 徐州赛区网络预赛 H)

    H.Ryuji doesn't want to study 27.34% 1000ms 262144K   Ryuji is not a good student, and he doesn't wa ...

  4. 2019~2020icpc亚洲区域赛徐州站H. Yuuki and a problem

    2019~2020icpc亚洲区域赛徐州站H. Yuuki and a problem 题意: 给定一个长度为\(n\)的序列,有两种操作: 1:单点修改. 2:查询区间\([L,R]\)范围内所有子 ...

  5. ACM-ICPC 2018 徐州赛区网络预赛 H Ryuji doesn't want to study (树状数组差分)

    https://nanti.jisuanke.com/t/31460 题意 两个操作.1:查询区间[l,r]的和,设长度为L=r-l+1, sum=a[l]*L+a[l+1]*(L-1)+...+a[ ...

  6. 计蒜客 31460 - Ryuji doesn't want to study - [线段树][2018ICPC徐州网络预赛H题]

    题目链接:https://nanti.jisuanke.com/t/31460 Ryuji is not a good student, and he doesn't want to study. B ...

  7. 2018徐州网络赛H. Ryuji doesn't want to study

    题目链接: https://nanti.jisuanke.com/t/31458 题解: 建立两个树状数组,第一个是,a[1]*n+a[2]*(n-1)....+a[n]*1;第二个是正常的a[1], ...

  8. ACM-ICPC 2018 徐州赛区网络预赛 H. Ryuji doesn't want to study

    262144K   Ryuji is not a good student, and he doesn't want to study. But there are n books he should ...

  9. 2019徐州网络赛 H.function

    题意: 先有\(n=p_1^{k_1}p_2^{k_2}\cdots p_m^{k_m}\),定义\(f(n)=k_1+k_2+\cdots+k_m\). 现在计算 \[ \sum_{i=1}^nf( ...

随机推荐

  1. Educational Codeforces Round 84 (Rated for Div. 2)

    A. Sum of Odd Integers(思维) 思路 这一题看完ans之后觉得是真简单,不过有一些地方还是要理解的. 这一题输出YES,有两个条件 kk%2 == n%2k,这个条件的意思是 k ...

  2. Unity 游戏框架搭建 2019 (二十五) 类的第一个作用 与 Obselete 属性

    在上一篇我们整理到了第七个示例,我们今天再接着往下整理.我们来看第八个示例: #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; ...

  3. python--匿名函数、文件操作

    一.匿名函数 语法: sum = lambda arg1, arg2: arg1 + arg2 #调用sum函数 print "Value of total : ", sum( 1 ...

  4. 【php】PDO

    一.PDO的定义 1.pdo(php data object)是一个数据库的抽象层 二.PDO的特点 1.跨数据库 2.支持预处理 3.支持事务处理 三.PDO的使用 1.基本使用 (1)实例化pdo ...

  5. UC接口文档

    UC接口文档 一.功能描述 提供同步登录.退出.注册等相关接口,可以实现用户一个账号,在一处登录,全站通行. 二.测试环境UC地址 http://s1.p5w.net/uc/ 三.相关接口 UC_AP ...

  6. protobuf总结

    1.protobuf是什么? protobuf(protocol buffers)是一种语言中立,平台无关,可扩展的序列化数据的格式,可以用于通信协议,数据存储等. protobuf 相比于xml,j ...

  7. Linux bash篇,基本信息和变量

    1.shells目录       /etc/shells 2.查看用户所具有的shell    /etc/passwd 3.查看当前用户执行过的shell      ~/.bash_history 4 ...

  8. "斜体显示"组件:<i> —— 快应用组件库H-UI

     <import name="i" src="../Common/ui/h-ui/text/c_tag_i"></import> &l ...

  9. hive常用函数四

    字符串函数 1. 字符串长度函数:length 语法: length(string A) 返回值: int 说明:返回字符串A的长度 举例: hive> select length('abced ...

  10. SpringMVC框架详细教程(二)

    创建动态Web项目 1.创建动态Web项目: 打开Eclipse,在Package Explorer右击,创建项目,选择动态Web项目(Dynamic Web Project). 填写项目名称,并选择 ...