ACM: 线段树 poj 3468
来源:互联网 发布:java回退流 编辑:程序博客网 时间:2024/05/17 01:47
You have N integers, A1,A2, ... , AN. You need to dealwith two kinds of operations. One type of operation is to add somegiven number to each number in a given interval. The other is toask for the sum of numbers in a given interval.
Input
The first line contains two numbers N and Q. 1 ≤N,Q ≤ 100000.
The second line contains N numbers, the initial values ofA1, A2, ... ,AN. -1000000000 ≤ Ai ≤1000000000.
Each of the next Q lines represents an operation.
"C a b c" means adding c to each ofAa, Aa+1, ... ,Ab. -10000 ≤ c ≤ 10000.
"Q a b" means querying the sum ofAa, Aa+1, ... ,Ab.
Output
You need to answer all Q commands in order. One answer ina line.
Sample Input
10 5
1 2 3 4 5 6 7 8 9 10
Q 4 4
Q 1 10
Q 2 4
C 3 6 3
Q 2 4
Sample Output
4
55
9
15
Hint
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 100005
{
}pt[MAX*4];
__int64 g[MAX];
__int64 a, b, c;
char ch[2];
__int64 result;
{
}
{
}
{
}
{
//
}
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1177
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 1151 足足想了三…
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 2482 煽情的情书!…
- poj 3321 Apple Tree 线段树
- poj 2182 Lost Cows 线段树
- 【线段树】 POJ 2828 Buy Tickets
- POj 2379 ACM Rank Table
- ACM: poj 1664
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 2482 煽情的情书!…
- C++ 友元类
- ACM: 树状数组 poj 1195
- ACM: 树状数组 poj 2155 学习《浅…
- ACM: 树状数组 poj 3321 图论+树状…
- spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244
- ACM: 线段树 poj 3264