题目大意: 一个数列,有两个操作:1.修改操作,将一段区间内的数加上c:2.查询操作,查询一段区间内的数的和. 思路: 线段树裸题,区间修改.区间查询,维护和以及加上的数,由于无序,不需要向下推标记,只需在子树更新完之后更新根节点即可. 代码: #include<cstdio> #include<cstring> #include<iostream> using namespace std; ],mor[]; void up(int cur,int t) { sum[c…
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec Memory Limit: 128 MB Submit: 1278 Solved: 560 [Submit][Status][Discuss] Description You have N integers, A1, A2, - , AN. You need to deal with two kinds of operations. One type of operati…
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2046  Solved: 892[Submit][Status][Discuss] Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of opera…
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2530  Solved: 1096[Submit][Status][Discuss] Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of oper…
一个有初值的数列.区间加.区间查 用线段树直接水过 然而并没有1A,主要是做题太快没看规模结果没注意线段树要用longlong建 卧槽怎么可以这么坑爹,害得我看见wa心慌了,还以为连线段树都要跪 一开始在写下传(MDZZ)然后发现没什么操作就删了 #include <cstdio> #include <iostream> #define mid (l+r)/2 ],tr[]; int n,m; void add(int now,int l,int r,int x,int y) {…
线段树入门题…… 因为poj原来的代码莫名RE,所以丧病地写了区间修改的分块…… 其实就是块上打标记,没有上传下传之类. #include<cstdio> #include<cmath> using namespace std; ],l[],r[],delta[],num[],sum,sz,x,y,v; ]; ]; void makeblock() { sz=sqrt(n); ;sum*sz<n;sum++) { l[sum]=(sum-)*sz+; r[sum]=sum*s…
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1053  Solved: 468[Submit][Status][Discuss] Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of opera…
3212: Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MB Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in…
Pku3468 A Simple Problem with Integers Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 2173  Solved: 951[Submit][Status][Discuss] Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation i…
http://poj.org/problem?id=3468 实现一个线段树,能够做到区间修改和区间查询和. 明显板子题. #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> using namespace std; typedef long long ll; inline ll read(){ ll X=,w=; ;…