区间开根号是不具备整体性的,即和开根号不一定等于开根号的和。但是由于由于在longlong范围内的数开根号7次就会变成一所以我们单点更新也是可以的,剪枝就是如果一个区间的和等于区间的大小就不用再继续向下更新了,实现也简单;
ps:再注意几个坑,每组样例结束要多输出一个空行,and l,r的大小不确定
ac:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
namespace {template <typename T> inline void read(T &x) {x = 0; T f = 1;char s = getchar();for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);x *= f;}
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (int i = (n); i < (m); i++)
#define _rep(n,m,i) for (int i = (n); i <= (m); i++)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e5+5;
LL T[N<<2];
void push_up(int rt) { T[rt] = T[rt<<1] + T[rt<<1|1];
}
void build(int rt, int l, int r) {if(l == r) { read(T[rt]);return ;} int mid = l + r >> 1;build(lson);build(rson);push_up(rt);
}
void updata(int rt, int l, int r, int L, int R) { if(L <= l && R >= r && T[rt] == r-l+1) return ;if(l == r) {T[rt] = sqrt(T[rt]);return ;}int mid = l + r >> 1;if(L <= mid) updata(lson, L, R);if(R >  mid) updata(rson, L, R);push_up(rt);
}
LL qry(int rt, int l, int r, int L, int R) {if(L <= l && r <= R) {return T[rt];}int mid = l + r >> 1;LL ret = 0;if(L <= mid) ret += qry(lson, L, R);if(R >  mid) ret += qry(rson, L, R);return ret;
}
int main() { int n,m,l,r,op;for(int id = 1; cin >> n; id++) {printf("Case #%d:\n", id);build(1,1,n);read(m);while(m--) {read(op);read(l);read(r);if(l > r) swap(l, r);if(op) printf("%lld\n", qry(1,1,n,l,r));else updata(1,1,n,l,r);}printf("\n");}
}

HDU-4037-线段树-区间开根号相关推荐

  1. POJ 2777 ZOJ 1610 HDU 1698 --线段树--区间更新

    直接将这3题 放一起了  今天在做线段树的东西 这3个都是区间更新的 查询方式互相不同 反正都可以放到一起吧 直接先上链接了 touch me touch me touch me 关于涉及到区间的修改 ...

  2. hdu 1698(线段树区间更新)

    解题思路:线段树区间更新水题. #include<iostream> #include<cstdio> #include<cstring> using namesp ...

  3. hdu 5367(线段树+区间合并)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5367 官方题解: 对于求"高山脉"长度,可以利用线段树.树节点中保存左高度连续长度 ...

  4. hdu 5124(线段树区间更新+lazy思想)

    http://acm.hdu.edu.cn/showproblem.php?pid=5124 题意:区间覆盖次数问题. 解题思路:线段树水之. #include<iostream> #in ...

  5. HDU - 4578Transformation——线段树+区间加法修改+区间乘法修改+区间置数+区间和查询+区间平方和查询+区间立方和查询

    [题目描述] HDU - 4578Transformation Problem Description Yuanfang is puzzled with the question below: The ...

  6. hdu 3954(线段树区间更新)

    转载标记处:http://www.cnblogs.com/wang-jue/articles/2920341.html 思路:这道题所得到的经验与每个英雄的等级有关,一般的可能就用线段树一直更新到每一 ...

  7. hdu 1806线段树 区间合并

    #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> us ...

  8. HDU - 6183 暴力,线段树动态开点,cdq分治

    B - Color itHDU - 6183 题目大意:有三种操作,0是清空所有点,1是给点(x,y)涂上颜色c,2是查询满足1<=a<=x,y1<=b<=y2的(a,b)点一 ...

  9. hdu 5692 Snacks(dfs序+线段树区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5692 解题思路:这道题是树节点的点权更新,而且涉及到子树,常用的思路是利用dfs序,用线段树来对区间进 ...

最新文章

  1. Django 缓存6.2
  2. Angular:Promise.all()的具体应用
  3. 后门BROOTKIT代码学习和原理分析
  4. Java并发编程基础与实战
  5. Windbg调试命令详解(3)
  6. 使用cout输出数据之使用成员函数
  7. 开发:异常收集之 ibatis+Oracle 查询时: ORA-00911错误
  8. Spring Boot定时任务-cron表达式
  9. 自定义EditText输入框
  10. linux 无法打开.ttf_win7系统ttf文件打不开怎么办【解决方法】
  11. ddos攻击工具_linux下DDoS攻击模拟实战
  12. 打造一个实际的全系统污点分析系统--Towards Practical Taint Tracking
  13. FPGA不可综合语句
  14. oracle存储过程传整数,oracle存储过程传参数
  15. ITF Demo代码(用VBScript构建的接口测试框架)
  16. 大写汉字转阿拉伯数字c语言,把中文汉字大写数字 转换成 阿拉伯数字
  17. PostgreSQL13 安装
  18. 为什么进行商业分析?什么是商业分析?(二)商业分析的角色、怎样进行商业分析与准备、相关方识别
  19. web前端技术——三、表单
  20. HTML5 Canvas组件绘制太极图案

热门文章

  1. onedrive 添加到本地硬盘_Windows平台下使用 Rclone 挂载 OneDrive 为本地硬盘
  2. 程序员实用工具网站(原文有图片,本篇只是简单记录)
  3. MySQL 表设计的经验准则
  4. 【kaggle】印度语和泰米尔语问答赛题baseline
  5. 三个可替代“迅雷”的下载软件,速度超快!
  6. c++语言 tcp例子,C++ boost::asio编程-同步TCP详解及实例代码
  7. No mapping found for HTTP request with URI问题解决
  8. 东方国信(实习一面)
  9. 用Android Studio编写简易闹钟(一)
  10. 北航c语言程序设计大一期末题库,北航2016C语言|程序设计题七