QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 256 MB Total points: 100

#11817. 谐振器

Statistics

Sun-glade Isle 作为一个传送门,是位于东海的一个重要军事要塞。几名顶尖特工成功登岛,占领了传送门,并暂时宣布了战斗的胜利。

为了加固传送门,他们在传送门周围部署了 $N$ 个谐振器。传送门的中心位于 $(0, 0)$。每个谐振器占据一个圆形区域。第 $i$ 个谐振器的中心为 $(x_i, y_i)$,半径为 $r_i$。这些圆形区域可能会重叠。

总防御能力是所有至少被一个谐振器覆盖的区域到传送门中心 $(0, 0)$ 的距离的平方之和。也就是说,如果存在一个足够小的区域被至少一个谐振器覆盖,那么该区域提供的防御能力等于其面积与到中心 $(0, 0)$ 距离平方的乘积。

如果我们设 $\Omega$ 为所有谐振器所覆盖区域的并集(即若干圆的并集),那么该传送门的总防御能力实际上是以下积分的结果:

$$\int_{\Omega} |v|^2 ds = \int_{\Omega} (x^2 + y^2) dx dy$$

作为情报部门的超级指挥官,你的任务是计算该传送门的总防御能力。

输入格式

输入包含多个测试用例,第一行给出一个整数,表示测试用例的数量(最多 50 个)。 对于每个测试用例,第一行包含一个整数 $N$ ($N \le 1000$),表示部署的谐振器总数。 接下来的 $N$ 行描述这些谐振器,第 $i$ 行包含三个整数 $x_i, y_i$ 和 $r_i$,其中 $|x_i|, |y_i| \le 100$ 且 $1 \le r_i \le 5$。

输出格式

对于每个测试用例,输出防御能力,保留三位小数。

样例

输入 1

3
1
0 0 1
2
0 0 1
1 0 1
3
0 0 1
1 0 1
0 1 1

输出 1

1.571
5.704
9.668

说明

对于样例中的第一个测试用例,答案为:

$$\int_{-1}^{1} \int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}} (x^2 + y^2) dy dx = \frac{\pi}{2} \approx 1.5708$$

第二个测试用例的答案是以下两项之和:

$$\int_{-1}^{1/2} \int_{-\sqrt{1-x^2}}^{\sqrt{1-x^2}} (x^2 + y^2) dy dx \approx 1.15545$$

以及

$$\int_{1/2}^{2} \int_{-\sqrt{1-(x-1)^2}}^{\sqrt{1-(x-1)^2}} (x^2 + y^2) dy dx \approx 4.54888$$

Figure 1. 区域 Ω 的示意图

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1282EditorialOpenEditorial for #11817Diaosi2026-03-16 15:04:04View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.