Trace

CodeForces - 157B

One day, as Sherlock Holmes was tracking down one very important criminal, he found a wonderful painting on the wall. This wall could be represented as a plane. The painting had several concentric circles that divided the wall into several parts. Some parts were painted red and all the other were painted blue. Besides, any two neighboring parts were painted different colors, that is, the red and the blue color were alternating, i. e. followed one after the other. The outer area of the wall (the area that lied outside all circles) was painted blue. Help Sherlock Holmes determine the total area of red parts of the wall.

Let us remind you that two circles are called concentric if their centers coincide. Several circles are called concentric if any two of them are concentric.

Input

The first line contains the single integer n (1 ≤ n ≤ 100). The second line contains n space-separated integers ri (1 ≤ ri ≤ 1000) — the circles' radii. It is guaranteed that all circles are different.

Output

Print the single real number — total area of the part of the wall that is painted red. The answer is accepted if absolute or relative error doesn't exceed 10 - 4.

Examples

Input
1
1
Output
3.1415926536
Input
3
1 4 2
Output
40.8407044967

Note

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 π × 12 = π.

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 (π × 42 - π × 22) + π × 12 = π × 12 + π = 13π

sol:小学奥数,为了防止丢精度,把R求出来,只用一次π。

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=;
const double Pi=3.141592653589793238;
int n;
double r[N];
int main()
{
int i;
double R=;
R(n);
for(i=;i<=n;i++) scanf("%lf",&r[i]);
sort(r+,r+n+);
for(i=n;i>=;i-=)
{
R+=r[i]*r[i];
}
for(i=n-;i>=;i-=)
{
R-=r[i]*r[i];
}
printf("%.10lf\n",Pi*R);
return ;
}
/*
input
1
1
output
3.1415926536 input
3
1 4 2
output
40.8407044967
*/

codeforces157B的更多相关文章

随机推荐

  1. 《HTTP协议:菜鸟入门系列》

    很多测试人员在有了一定的测试经验(一般是1-2年)后,就会陷入瓶颈阶段,想提升,但不知道如何提升,学习又没有比较明确的方向,曾经我也是... 那么,我建议系统的学习一下HTTP协议,好处很多:对接口测 ...

  2. python调用数据返回字典dict数据的现象2

    python调用数据返回字典dict数据的现象2 思考: 话题1连接:https://www.cnblogs.com/zwgbk/p/10248479.html在打印和添加时候加上内存地址id(),可 ...

  3. H5海报制作实践

    引言 年后一直处于秣马厉兵的状态,上周接到了一个紧急需求,为38妇女节做一个活动页,主要功能是生成海报,第一次做这种需求,我也是个半桶水前端,这里将碰到的问题.踩的坑,如何解决的分享给大家,讲的不到位 ...

  4. Sql Server中的nvarchar(n)、varchar(n) 和Mysql中的char(n)、varchar(n)

    刚才有幸看了下 nvarchar(n)和varchar(n),感觉以前的认知有误. nvarchar(n):n指的是字符个数,范围是1-4000,存储的是可变长度的Unicode字符数据. 按字符存储 ...

  5. Python学习第三篇——访问列表部分元素

    dongman =["huoying","sishen","si wang bi ji","pan ni de lu lu xiu ...

  6. tortoisegit密钥与git密钥配置

    在客户端生成密钥并将公钥上传到服务器可以避免每次连接git服务器都要登录的尴尬. 但git的私钥是不能直接用在tortoisegit上的,需要用tortoisegit的puttygen转换一下,详细过 ...

  7. 在网站开发时,可以设置防盗,不被复制和F12

    禁止小功能 //禁止右键 document.oncontextmenu = function () { return false } //禁止f12 document.onkeydown = func ...

  8. IntelliJ IDEA/WebStrom破解及JDK配置

    title: IntelliJ IDEA/WebStrom破解及JDK配置 (一)破解 破解步骤 第一步:下载破解补丁 第二步:修改配置文件 第三步:重启IntelliJ IDEA/WebStrom填 ...

  9. CentOS6.5配置 cron

    CentOS6.5配置 cron 任务 - mengjiaoduan的博客 - CSDN博客https://blog.csdn.net/mengjiaoduan/article/details/649 ...

  10. C#设计模式之3:观察者模式

    C#中已经实现了观察者模式,那就是事件,事件封装了委托,使得委托的封装性更好,在类的内部定义事件,然后在客户端对事件进行注册: public class Subject { public event ...