线段树区间更新&&求和poj3486】的更多相关文章

给出了一个序列,你需要处理如下两种询问. ≤ c ≤ ). "Q a b" 询问[a, b]区间中所有值的和. Input 第一行包含两个整数N, Q. ≤ N,Q ≤ . 第二行包含n个整数,表示初始的序列A (- ≤ Ai ≤ ). 接下来Q行询问, Sample Input Q Q Q C Q Sample Output #include<iostream> #include<stdio.h> #include<cstring> using n…
一开始这条链子全都是1 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<map> using namespace std; ///线段树 区间更新 #define MAX 100050 struct node { int left; int right; int mark; int total; }; node tree[MAX*…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 75541   Accepted: 23286 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
很模板的题 在建树的时候输入 求和后更新 #include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> #include<map> using namespace std; ///线段树 成段更新 struct node { int l; int r; int total; int mark; }; node a[100050*4]; int c[100050]…
A Simple Problem with Integers   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 a given interval. The other is to ask for the sum o…
Just a Hook Problem Description In the game of DotA, Pudge's meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do some ope…
题意:给出一颗树形图,有三种操作,I:在u到v的路径上的每个点的权值+d,D:在u到v的路径上的每个点的权值都-d,Q询问u点的权值 #pragma comment(linker, "/STACK:1024000000,1024000000") #include"stdio.h" #include"string.h" #include"stdlib.h" #include"algorithm" #inclu…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 141093   Accepted: 43762 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 24474    Accepted Submission(s): 12194 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing…
题目链接: http://poj.org/problem?id=3468 题意: 输入 n, m表初始有 n 个数, 接下来 m 行输入, Q x y 表示询问区间 [x, y]的和: C x y z 表示区间 [x, y] 内所有数加上 z : 思路: 线段树区间更新&区间求和模板: 代码: #include <iostream> #include <stdio.h> #define ll long long #define lson l, mid, rt <<…