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. simpleRNN

    simpleRNN 训练集为<爱丽丝梦境>英文版txt文档,目标:根据随机给出的10个字符,生成可能的后100个字符 词向量空间生产 In [4]: INPUT_FILE = " ...

  2. A Translation for Quaternion 一篇对四元数的翻译

    一篇写的非常好的博客:http://www.cnblogs.com/lookof/archive/2012/02/24/2360749.html

  3. APP消息推送功能

    1.APP内部最好设计-我的消息-的功能,以便用户查看推送消息历史记录,通过角标.已读.未读等设计吸引用户读取消息.(画下来这都是重点) 2.建议提供推送设置功能,允许用户设置推送消息是否显示于通知栏 ...

  4. 在intellij中使用checkStyle进行代码规范

    1 编写代码检测规则可以参考阿里和google的规则和checkstyle的官网文档.checkstyle官网地址http://checkstyle.sourceforge.net/ 假设自己的sty ...

  5. LayerMask小结

    layerMask参数: Raycast (ray : Ray, out hitInfo : RaycastHit, distance : float = Mathf.Infinity, layerM ...

  6. Atitit.设计模式-----触发器模式 trigger  详解

    Atitit.设计模式-----触发器模式 trigger  详解 1. 触发器概念1 1.1. 触发器位置 after|before|instead of1 2. 数据库里面的触发器1 2.1. o ...

  7. [svc]linux文件特殊权限

    这是老以前写的文章, 断断续续的可见那时候的心态还是不稳的. 生产使用: g1,g2组2个组的员工,  g2组要访问g1组/home下的文件,rx权限.  这个setfacl就有用. 方法1: 修改普 ...

  8. windows server 2003下搭建amp环境

    参考: http://blog.csdn.net/binyao02123202/article/details/7578914 http://4359260.blog.51cto.com/434926 ...

  9. springboot2.0 fastjson 日期格式化不生效解决

    网上有很多介绍,主要有两种. 1.在启动类中注入bean /** * 集成fastjson * * @return */ @Bean public HttpMessageConverters fast ...

  10. C++Primer学习笔记《2》

    数组是一种复合类型,由类型名+数组名+维度组成. 数组定义中的类型能够是C++基本内置类型.也能够是类类型的.数组元素的类型能够是除了引用类型以外的其它不论什么类型.没有全部的元素都是引用的数组. 数 ...