题意: 给一个序列,初始全为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…
自己写了一个带结构体的WA了7.8次 但是测了几组小数据都对..感觉问题应该出在模运算那里.写完这波题解去对拍一下. 以后线段树绝不写struct!一般的struct都带上l,r 但是一条线段的长度确定的话,每一个节点的l,r都可以确定的,没必要用struct存上,如果不带上l,r那不是更没必要用结构体hhh 这道题有点坑的地方就是顺序问题 pushdown就是一个最大的难点 change表示改数字 add表示加上数字 multiply表示乘以一个数字 正确的方法应该是 先change 再mul…
Yuanfang is puzzled with the question below: There are n integers, a 1, a 2, …, a n. The initial values of them are 0. There are four kinds of operations. Operation 1: Add c to each number between a x and a y inclusive. In other words, do transformat…
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…
Attack Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 2496    Accepted Submission(s): 788 Problem Description Today is the 10th Annual of “September 11 attacks”, the Al Qaeda is about to attack…
Coder Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4838    Accepted Submission(s): 1853 Problem Description In mathematics and computer science, an algorithm describes a set of procedures…
Man Down Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2030    Accepted Submission(s): 743 Problem Description The Game “Man Down 100 floors” is an famous and interesting game.You can enjoy t…
题目链接: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…
https://cn.vjudge.net/problem/HDU-4578 题意 4种操作,区间加,区间乘,区间变为一个数,求区间的和.平方和以及立方和. 分析 明显线段树,不过很麻烦..看kuangbin大神的代码打的 用sum1,sum2,sum3分别代表和.平方和.立方和. 懒惰标记使用三个变量: lazy1:是加的数 lazy2:是乘的倍数 lazy3:是赋值为一个常数,为0表示没有. #include <stdio.h> #include <string.h> #inc…