The first step of the solution is a fairly standard observation: we can count the desired answer in a different way. Instead of computing the average number of carrots inside the blast radius (by integrating over the coordinates of impact), we can get the same answer as follows: For each carrot, we compute the probability that it is hit by the blast. The answer is then simply the sum of all those probabilities. (This follows from linearity of expectation.) This was an important step because it transformed our problem into a discrete one. What is the probability that a bomb will hit a particular carrot C? Draw a circle with radius R centered at C, and take its intersection with the rectangle. The probability is the area of the shape S[C] you just constructed, divided by the area of the rectangle. And as the rectangle is the same for all points, we can do the division only once, at the very end. Thus, our problem statement reduces to computing the sum of areas of all S[C]. We can simplify our life even further by only considering one quarter of each circle: the one in the top right quadrant. By symmetry, the sum we'll compute will be 1/4 of the sum of all S[C]. The figure below shows some of the shapes we'll be adding up. FIXME: on some fine later day, pictures will appear here. And that's as far as we can simplify the problem. Now we actually have to count. With 100k times 100k points, we cannot process them one at a time. Instead, we have to be smarter. But let's start by looking at the solution that processes the points one at a time. Imagine a row of points. From each of them we will draw a quarter of a circle that points up and to the right, we will intersect it with the rectangle, and compute the area of the result. Imagine starting at the rightmost point. The area for this point is clearly 0. Let's move one point to the left. In the general case (imagine that the row of points is close to the top) the area will now be a rectangle of width 1. As we move farther to the left, the area will start having a curved right side, and finally it will remain constant. How can we compute all those areas quickly? By precomputing something useful. Namely, take the quarter of the circle and slice it by vertical stripes of width 1. You will get a bunch of pieces. Compute the area of each of them, and then the prefix sums of those areas *from the right to the left*, and then the prefix sums of *those values*. That should be enough to compute the sum of our areas for an entire row of points in constant time. (Once again, sorry about the missing pictures, drawing them takes too much time.)