logo AlgoBeat OnlineJudge
登录 注册

#217320. [ICPC 2017 Nanning R] Resonators

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

:::align{center} :::

The Sun-glade Isle as a portal is an important military fortress, located in the East China Sea. Several finest agents climbed onto the island successfully. They captured the portal and declared the victory of the battle, temporarily.

To reinforce the portal, they deployed resonators around the portal. The centre of the portal is located at . A resonator occupies a circular area. The centre of the -th one is and its radius is . These circular areas are likely to overlap.

The total defense capability is the sum of squared distances to the centre of the portal from the locations which be occupied by at least one resonator. That is say that if there is a sufficient small region occupied by at least one resonator, this region would offer the defense capability up to the product of the area, and the squared distance to the centre .

If we suppose as the union of all resonators which is the union of several circles. The total defense capability of this portal is actually the result of the following integral:

Here is your mission, as a super leader the Intel. Compute the total defense capability of this portal.

输入格式

The input contains several test cases and the first line of input gives the number of test cases which is up to .

For each test case, the first line contains the integer which is the total number of resonates deployed. The following lines describe these resonators and the -th line contains three integers , and , where and .

输出格式

For each test case output the defense capability rounding up to three decimal places.

样例

样例输入 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

数据范围与提示

For the first test case in the sample, the answer if

The answer of the second test case is the sum of

and