HDU 5634 Rikka with Phi 线段树】的更多相关文章

题意:bc round 73 div1 D 中文题面 分析:注意到10^7之内的数最多phi O(log(n))次就会变成1, 因此可以考虑把一段相同的不为1的数缩成一个点,用平衡树来维护. 每次求phi的时候就在平衡树上取出这个区间然后暴力求phi,如果一段数变成了1, 就在平衡树里面删掉它,最后统计答案的时候只要把区间中被删去的1加回答案即可, 时间复杂度O((n + m)logn) 注:平衡树,写起来麻烦(然后其实我也不会写) 但是题解当中说把一段相同的数缩成一个点,就很好 所以用线段树,…
// HDU5634 Rikka with Phi 线段树 // 思路:操作1的时候,判断一下当前区间是不是每个数都相等,在每个数相等的区间上操作.相当于lazy,不必更新到底. #include <bits/stdc++.h> using namespace std; #define clc(a,b) memset(a,b,sizeof(a)) #define inf 0x3f3f3f3f #define lson l,mid,rt<<1 #define rson mid+1,r…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5634 -------------------------------------------------------------------------------------------- 官方题解上给的是用平衡树写 不过用类似的思路 也是可以用线段树去写的 操作$2$区间赋为相同值可以直接按照常规的线段树的题目去写 操作$1$是只减不增的 而且最多$log$次会减少到$1$ 所以大量使用$1$操…
Rikka with Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5828 Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A wi…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6089 题解 这波强行维护搞得我很懵逼... 扫描线,只考虑每个点能走到左上方(不包括正上方,但包括正左方)的哪些点,然后旋转四次坐标系处理 所有询问和操作点按照先\(x\)后\(y\)坐标的顺序排序,然后枚举每一行,按\(y\)从小到大的顺序枚举这一行每个点 对于一个询问点找出前面最后一个操作点,那么要求的就是一个矩形减去一个区间内所有后缀最大值的和 然后这个东西可以用线段树直接维护,记录个区间最大…
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem. There is a very long board with length L centimeter, L is a positive integer, so we can evenly divide the bo…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5828 给你n个数,三种操作.操作1是将l到r之间的数都加上x:操作2是将l到r之间的数都开方:操作3是求出l到r之间的和. 操作1和3就不说了,关键是开方操作. 一个一个开方,复杂度太高,无疑会T.所以我们来剪枝一下. 我们可以观察,这里一个数最多开方4,5次(loglogx次)就会到1,所以要是一段区间最大值为1的话,就不需要递归开方下去了.这是一个剪枝. 如果一段区间的数都是一样大小(最大值等于…
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A with n numbers. Then he makes m operations on it. There are three ty…
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A with n numbers. Then he make…
HDU 3016 Man Down (线段树+dp) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1391    Accepted Submission(s): 483 Problem Description The Game “Man Down 100 floors” is an famous and interesting ga…