![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树状数组
文章平均质量分 85
Nowara_Shinnosuke
这个作者很懒,什么都没留下…
展开
-
树状数组
一. 基本原理从图中可以看到,树状数组中用的C[],每个点都有一定的管辖范围;如C[1]=a[1];C[2]=a[1]+a[2];C[3]=a[3];C[4]=a[1]+a[2]+a[3]+a[4];等等;这样的结构关键是为了,对一个数组内部动态的删除,增加,来高效的求某个点或者某个区间的值;比如说对数组a,改变某转载 2017-05-16 15:39:46 · 294 阅读 · 0 评论 -
Apple Tree
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.The tree has N转载 2017-05-20 10:27:08 · 880 阅读 · 0 评论 -
MooFest
Every year, Farmer John's N (1 <= N <= 20,000) cows attend "MooFest",a social gathering of cows from around the world. MooFest involves a variety of events including haybale stacking, fence jumping, p原创 2017-05-19 12:21:52 · 541 阅读 · 0 评论 -
Cube
Given an N*N*N cube A, whose elements are either 0 or 1. Ai,j,ki,j,k means the number in the i-th row , j-th column and k-th layer. Initially we have Ai,j,ki,j,k = 0 (1 We define two operations,原创 2017-05-19 10:37:11 · 395 阅读 · 0 评论 -
BST
Consider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root node is X, we can get the minimum number in this subtree by repe原创 2017-05-18 23:03:39 · 487 阅读 · 0 评论 -
Cows
Farmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer John has N原创 2017-05-18 15:56:18 · 629 阅读 · 0 评论 -
Mobile phones
Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares form an S * S matrix with the rows and columns numbe原创 2017-05-18 14:21:37 · 282 阅读 · 0 评论 -
Japan
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <= 1000, N <= 10原创 2017-05-18 13:43:54 · 283 阅读 · 0 评论 -
Matrix
Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 We can change the matrix in the following way. G原创 2017-05-17 23:33:32 · 216 阅读 · 0 评论 -
Ultra-QuickSort
In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted i原创 2017-05-17 12:54:36 · 300 阅读 · 0 评论 -
Color the ball
Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 19849 Accepted Submission(s): 9897Problem DescriptionN个气球排成一排,从左到右依次编号为1,原创 2017-05-17 11:13:29 · 224 阅读 · 0 评论 -
Stars
StarsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 46750 Accepted: 20155DescriptionAstronomers often examine star maps where stars are represented by原创 2017-05-16 22:26:46 · 290 阅读 · 0 评论 -
x&(-x) 的值
x&(-x),当x为0时结果为0;x为奇数时,结果为1;x为偶数时,结果为x中2的最大次方的因子。 比如x=32,其中2的最大次方因子为2^5,故x&(-x)结果为32;当x=28,其中2的最大次方因子为4,故x & (-x)结果为4。当x=24,其中2的最大次方因子为8,故 x&(-x)结果为8。x&(-x),当x为0时结果为0;x为奇数时,结果为1;x为偶数时,结果为x中2的最大转载 2017-05-16 17:04:31 · 1156 阅读 · 0 评论 -
Enemy is weak
The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep".Nevertheless Shapur has to fin原创 2017-05-20 13:06:36 · 373 阅读 · 0 评论