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;
}

CodeForces 157B Trace的更多相关文章

  1. codeforces157B

    Trace CodeForces - 157B One day, as Sherlock Holmes was tracking down one very important criminal, h ...

  2. OUC_Summer Training_ DIV2_#5

    这是做的最好的一次了一共做了4道题  嘻嘻~ A - Game Outcome Time Limit:2000MS     Memory Limit:262144KB     64bit IO For ...

  3. HTTP Method详细解读(`GET` `HEAD` `POST` `OPTIONS` `PUT` `DELETE` `TRACE` `CONNECT`)

    前言 HTTP Method的历史: HTTP 0.9 这个版本只有GET方法 HTTP 1.0 这个版本有GET HEAD POST这三个方法 HTTP 1.1 这个版本是当前版本,包含GET HE ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. Django中使用haystack进行全文检索时需要注意的坑

    对于haystack的配置什么的我在这里就不必说什么了,毕竟一搜一大把. 直接说重点 1 当你通过继承haystack的views来自定义django 应用的views 时,你要注意heystack ...

  2. 【软件project】——软工视频总结

    软件project是一门研究用project化方法构建和维护有效的.有用的和高质量的软件的学科.它涉及程序设计语言.数据库.软件开发工具.系统平台.标准.设计模式等方面. 软工,基本的六阶段:制定计划 ...

  3. 特征组合&特征交叉

    https://segmentfault.com/a/1190000014799038 https://www.jianshu.com/p/fc96675b6f8e https://blog.csdn ...

  4. visual studio 2017无建模项目?

    教一跨行同事学C#,我想从基础的讲一下,也就是最基本的面象对象分析与设计(OOAD),我直接打开我最新安装的 visual studio 2017.准备建一个“建模项目”.结果发现死活找不到?打开一个 ...

  5. struts2 在拦截器进行注入(依据Action是否实现自己定义接口)

    比如:经常在Action中都须要获取当前登录的User,就须要获取Session.然后从Session获取当前登录的User,由于这些步骤都是反复操作,能够想办法在拦截器中进行实现.能够自己定义一个接 ...

  6. [转]手工释放linux内存——/proc/sys/vm/drop_caches

    另一篇:http://www.linuxfly.org/post/320/   1.清理前内存使用情况 free -m 2.开始清理  echo 1 > /proc/sys/vm/drop_ca ...

  7. 转:python之如何在某文件中调用其他文件内的函数

    假设名为A.py的文件需要调用B.py文件内的C(x,y)函数 情形1:在同一目录下, (1) import B if __name__ == "__main__": B.C(x, ...

  8. 压力测试工具siege

    最近整改了一个线上服务,功能自测完毕后,需要进行性能的压力测试,同事推荐了siege这个工具,先熟悉一下相关的东西,后面有时间再好好研究它的源码实现.本文仅仅简单介绍一下这个工具的使用方法. 1.下载 ...

  9. 从Python的角度来看编码与解码

    导语: Python2和Python3中,因为默认字符集的不同而造成的麻烦,简直是程序员的梦魇!要彻底告别这个麻烦,就需要从本质上来理解编码和解码. 为什么要有编码? 对于不会英文的中国人来说,将英文 ...

  10. PHP特性整合(PHP5.X到PHP7.1.x)

    Buid-in web server内置了一个简单的Web服务器 把当前目录作为Root Document只需要这条命令即可: php -S localhost:3300 也可以指定其它路径 php ...