HDU P4578 Transformation】的更多相关文章

Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each number between ax and ay inclusive. In other words,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each…
http://acm.hdu.edu.cn/showproblem.php?pid=4578 题目大意:对于一个给定序列,序列内所有数的初始值为0,有4种操作.1:区间(x, y)内的所有数字全部加上C:2:区间(x, y)内所有数字全部乘C; 3:区间(x, y)内的所有数字全部重置为C: 4:输出区间(x, y)内所有数字的P次方的和.由于题目为多实例(至少10组样例),故很耿直的更新到叶子节点明显会TLE:因此需优化.可发现题目所有操作都是对区间进行,因此只需要更新 到区间内数字相同即可.…
http://acm.hdu.edu.cn/showproblem.php?pid=4578 题意:1,a,b,c代表在a,b区间的每一个数加上c:2,a,b,c代表在a,b区间的每一个数乘上c: 3,a,b,c代表在a,b区间的每一个数变为c:4,a,b,c是求在a,b区间的每一个数的c次方的和. 先乘后加. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 100010 us…
Transformation Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 65535/65536 K (Java/Others)Total Submission(s): 49    Accepted Submission(s): 16 Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2, …,…
Transformation Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 65535/65536 K (Java/Others)Total Submission(s): 3830    Accepted Submission(s): 940 Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2,…
Transformation Time Limit: 15000/8000 MS (Java/Others)    Memory Limit: 65535/65536 K (Java/Others)Total Submission(s): 10082    Accepted Submission(s): 2609 Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a…
题意: 给一个序列,初始全为0,然后有4种操作: 1. 给区间[L,R]所有值+c 2.给区间[L,R]所有值乘c 3.设置区间[L,R]所有值为c 4.查询[L,R]的p次方和(1<=p<=3) 解法: 线段树,维护三个标记,addmark,mulmark,setmark分别表示3种更新,然后p[1],p[2],p[3]分别表示该节点的1,2,3次方和.标记传递顺序setmark一定是第一个,因为setmark可以使mulmark,addmark都失效还原,mulmark和addmark的顺…
没什么说的裸线段树,注意细节就好了!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1.0) #define MAX 100003…
线段树上的多操作... 题目大意: 树上 的初始值为0,然后有下列三种操作和求和. 1  x y c  在X-Y的之间全部加上C. 2  x y c  在X-Y的之间全部乘上C. 3  x y c  在X-Y之间的全部变成C. 4  x y c  输出在X-Y之间的所有数的C方的和... 思路: 因为存在两种不兼容的操作(如果直接放一起的话会出现顺序不同的影响,(3+2)*4   和 3*4+2  显然是不一样的) 所以每次合并操作的时候  就要把子树的操作推下去清除掉. 当然  如果这个区间的…