POJ-A Simple Problem with Integers】的更多相关文章

题目:http://poj.org/problem?id=3468   A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 85851   Accepted: 26685 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 105742   Accepted: 33031 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 112228   Accepted: 34905 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type o…
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 of numbers in a given interval. Input The firs…
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 of numbers in a given interval. In…
#include<cstdio> #include<algorithm> #include<cstring> typedef long long ll; #define N 100010 using namespace std; struct node { ll l,r,lz,sum; }t[*N]; ll read() { ll ret=,neg=; char j=getchar(); ';j=getchar()) ; ';j=getchar()) ret=ret*+…
完全不知道该怎么用,看书稍微懂了点. 题意: 给定序列及操作,求区间和. 分析: 树状数组可以高效的求出连续一段元素之和或更新单个元素的值.但是无法高效的给某一个区间的所有元素同时加个值. 不能直接用树状数组求,就处理一下.用两个树状数组维护两个数据,一个维护前i项和,一个维护增加的值.设: ∑j=1iaj=sum(bit1,i)∗i+sum(bit0,i) 那么[l,r]区间上同时加上x就可以表示为: 对于bit0来说,在l位置上加上−x∗(l−1),在r+1位置上加上x∗r 对于bit1来说…
题意: 给定序列及操作,求区间和. 分析: 线段树,每个节点维护两个数据: 该区间每个元素所加的值 该区间元素和 可以分为"路过"该区间和"完全覆盖"该区间考虑. 代码: #include<cstdio> #include<iostream> #include<cmath> using namespace std; typedef long long ll; //[l,r) const int maxn = 300005; ll…
A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 58269   Accepted: 17753 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of…
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 of…