CF157B Trace
题目描述
一天,夏洛克·福尔摩斯正在跟踪一个重要罪犯时,他在墙上发现了一张美妙的画。这个墙可以被表示成一个平面,墙上有许多同心圆,将平面分成了若干块。除此之外,相邻的两个部分被交错填上了红色和蓝色。其中在所有圆外的部分被填了蓝色。夏洛克想知道红色部分的面积是多少。
输入格式
第一行包含一个整数 n(1≤n≤100)。
第二行包含 n 个整数 ri(1≤ri≤1000),表示每个圆的半径。保证每个圆大小不同。
输出格式
输出一行一个实数,表示红色部分的面积。如果你的答案和标准答案的绝对或相对误差小于 10−4 就被认为正确。
样例
样例输入 1
1
1
样例输出 1
3.1415926536
样例解释 1
只有一个半径为 1 的圆,红色部分是这个圆的内部,面积为 π。
样例输入 2
3
1 4 2
样例输出 2
40.8407044967
样例解释 2
所有圆的外侧为蓝色,第二个第三个圆中间是红色,第一第三个圆中间是蓝色,第一圆内是红色。总面积为 (π×42−π×22)+π×12=12π+π=13π
说明/提示
In the first sample the picture is just one circle of radius $ 1 $ . Inner part of the circle is painted red. The area of the red part equals $ π×1^{2}=π $ .
In the second sample there are three circles of radii $ 1 $ , $ 4 $ and $ 2 $ . Outside part of the second circle is painted blue. Part between the second and the third circles is painted red. Part between the first and the third is painted blue. And, finally, the inner part of the first circle is painted red. Overall there are two red parts: the ring between the second and the third circles and the inner part of the first circle. Total area of the red parts is equal $ (π×4^{2}-π×2^{2})+π×1^{2}=π×12+π=13π $