B. Trace
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h> using namespace std;
double pi=2*asin(1.0);
int n;
double a[105];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%lf",&a[i]);
sort(a+1,a+n+1);
double sum;
if(n&1)
{
sum=pi*a[1]*a[1];
for(int i=2;i<=n;i+=2)
{
sum+=pi*(a[i+1]*a[i+1]-a[i]*a[i]);
}
}
else
{
sum=0;
for(int i=2;i<=n;i+=2)
{
sum+=pi*(a[i]*a[i]-a[i-1]*a[i-1]);
}
}
printf("%lf\n",sum);
return 0;
}

最新文章

  1. Java02
  2. DOM4J的使用
  3. Vim保存只读模式下的修改
  4. php第三方登陆
  5. Redis中7种集合类型应用场景&amp;redis常用命令
  6. 《Python核心编程》 第十章 错误和异常
  7. javascript中的函数返回值(return)
  8. 基本RC积分电路及原理分析
  9. 一年三篇IF大于7的牛人告诉你怎么写SCI
  10. 纯css去实现loading动画效果图
  11. cocos2d-x代码阅读笔记 - 入口
  12. 生成1~n的排列,以及生成可重集的排列
  13. ABP入门系列(5)——展现层实现增删改查
  14. 洛谷 p1090 合并果子
  15. Java技术——Java中的static关键字解析
  16. android json解析及简单例子+Android与服务器端数据交互+Android精彩案例【申明:来源于网络】
  17. 转:sql篇 select from where group by having order by
  18. 【Jmeter自学】Jmeter脚本录制(二)
  19. 如何在Struts2的拦截器中调用Spring容器
  20. Kafka高可用实现

热门文章

  1. MySQL主从(MySQL proxy Lua读写分离设置,一主多从同步配置,分库分表方案)
  2. atitit.md5算法的原理&#160;与&#160;总结
  3. springboot文件上传下载,转载的
  4. 日志分析工具--GoAccess的安装部署
  5. Linux之实用GDB技巧
  6. QT界面 使用QStyledItemDelegate QPainter QStyleOptionViewItem QModelIndex组合实现项的绘制
  7. HDU 1020 Encoding 模拟
  8. linux web.py spawn-fcgi web.py 配置
  9. Maven 安装教程
  10. .net 编码常见问题