#include<iostream>
#include<cstring>
#include<cstdio>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e5+;
ll a[N];
int n,m;
int op,l,r;
struct node
{
ll l,r;
ll sum;
}tr[N*];
void build(int root,int l, int r)
{
tr[root]={l,r};
tr[root].sum=;
if(l==r)
{
tr[root].sum=a[l];
return;
}
int mid=l+r>>;
build(root<<,l,mid);
build(root<<|,mid+,r);
tr[root].sum=tr[root<<].sum+tr[root<<|].sum;
}
void update(int root,int l,int r)
{
if(l>tr[root].r||tr[root].l>r)
return;
if (tr[root].sum==(tr[root].r-tr[root].l + ))
return;
if (tr[root].l==tr[root].r)
{
tr[root].sum=sqrt(tr[root].sum);
return;
}
int mid=tr[root].l+tr[root].r>>;
update(root<<,l,r);
update(root<<|,l,r);
tr[root].sum=tr[root<<].sum+tr[root<<|].sum;
}
ll Query(int root,int l,int r)
{
if (l>tr[root].r||tr[root].l>r)
return ;
if (l<=tr[root].l&&tr[root].r<=r)
return tr[root].sum;
int mid=tr[root].l+tr[root].r>>;
ll res=;
res+=Query(root<<,l,r);
res+=Query(root<<|,l,r);
return res;
}
int main()
{
int cnt=;
while(~scanf("%d",&n))
{
printf("Case #%d:\n",++cnt);
for (int i=;i<=n;i++)
scanf("%lld",&a[i]);
scanf("%d",&m);
build(,,n);
while (m--)
{
scanf("%d%d%d",&op,&l,&r);
if(l>r)
swap(l,r);
if(op==)
update(,l,r);
else
printf("%lld\n",Query(,l,r));
}
printf("\n");
}
return ;
}

最新文章

  1. C#操作SQLite数据库
  2. cairo-1.14.6 static compiler msys mingw32
  3. Could not load file or assembly &#39;System.Core, Version=2.0.5.0 和autofac冲突的问题
  4. linux下安装openssh-server
  5. Java基础之访问文件与目录——测试文件或目录的路径(TryPath)
  6. (Java)《head first java》值得Java或面向对象基础的新手看。
  7. Python引用传值总结
  8. OC基础1:一些基本概念
  9. [计算机基础]关于实体( Entity )和模型( Model )
  10. 媲美jQuery的JS框架----AngularJS(二)
  11. 护航者,腾讯云: 2017年度游戏行业DDoS态势报告—回溯与前瞻
  12. Redis调用的流程(新手使用)
  13. January 19th, 2018 Week 3rd Friday
  14. IO model
  15. SCOPE_IDENTITY的用法【转载】
  16. Fibonacci(矩阵)
  17. SpringCloud服务消费者第一次调用出现超时问题的解决方案
  18. 漫谈NIO(2)之Java的NIO
  19. KETTLE元数据表
  20. 深入理解javascript作用域系列第五篇

热门文章

  1. 16、ISDN
  2. Asp.net core 2.x/3.x 的 Globalization 和 localization 的使用 (一) 使用方法
  3. Codeforces 924 A Tritonic Iridescence(暴力集合交集、相等)
  4. SpringBoot学习笔记 文件访问映射
  5. NR / 5G - MAC Overview
  6. Day5前端学习之路——盒模型和浮动
  7. Python性能优化方案
  8. OpenResty 在马蜂窝广告监测中的应用
  9. 0x01 C语言-编写第一个hello world
  10. markdown语法链接新页面打开