acd Convex(求面积)

Problem Description

We have a special convex that all points have the same distance to origin point.

As you know we can get N segments after linking the origin point and the points on the convex. We can also get N angles between each pair of the neighbor segments.

Now give you the data about the angle, please calculate the area of the convex.

Input

There are multiple test cases.

The first line contains two integer N and D indicating the number of the points and their distance to origin. (3 <= N <= 10, 1 <= D <= 10)

The next lines contains N integers indicating the angles. The sum of the N numbers is always 360.

Output

For each test case output one float numbers indicating the area of the convex. The printed values should have 3 digits after the decimal point.

Sample Input

4 1
90 90 90 90
6 1
60 60 60 60 60 60

Sample Output

2.000
2.598
多边形分成多个三角形,利用面积s=1/2*d*d*sin(角度的弧度)
#include<stdio.h>
#include<math.h>
#define PI 3.1415926
int main()
{
    int n;
    double d,c,sum;
    while(scanf("%d%lf",&n,&d)>0)
    {
        sum=0;
        while(n--)
        {
            scanf("%lf",&c);
            sum+=sin(c/180*PI);
        }
        sum=sum/2*d*d;
        printf("%.3lf\n",sum);
    }
}

acd Convex(求面积)

时间: 2024-10-06 01:17:47

acd Convex(求面积)的相关文章

uva 10065 (凸包+求面积)

链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=1006 Problem A Useless Tile Packers Input: standard input Output: standard output Yes, as you have apprehended the Useless Tile Pac

【POJ 1408】 Fishnet (叉积求面积)

[POJ 1408] Fishnet (叉积求面积) 一个1*1㎡的池塘 有2*n条线代表渔网 问这些网中围出来的最大面积 一个有效面积是相邻两行和相邻两列中间夹的四边形 Input为n 后面跟着四行 每行n个浮点数 每一行分别代表a,b,c,d 如图 并且保证a(i) > a(i-1) b(i) > b(i-1) c(i) > c(i-1) d(i) > d(i-1) n(n <= 30)*2+4(四个岸)条边 枚举点数就行 相邻的四个四个点枚举 找出围出的最大面积 找点用

poj 1265 Area (Pick定理+求面积)

链接:http://poj.org/problem?id=1265 Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4969   Accepted: 2231 Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionag

zoj 1010 (线段相交判断+多边形求面积)

链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=10 Area Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Jerry, a middle school student, addicts himself to mathematical research. Maybe the problems he has thought are

zoj 1010 Area 判断线段是否相交(把线段扩充一倍后 好处理) + 多边形求面积

题目来源: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=10 题意:  给定n个点的, 如果这n个点不能形成多边形 以及 n < 3 时, 输出, "Impossible",  否则 输出 多边形的面积. 分析: 这题主要在 分析  n 个点 是否形成 多边形.  枚举 每条边,  看 这条边 是否与 其他 n - 3 条边 不规范相交. (当处理 其他 边时, 我们采用 扩充线段一倍) 代码如下: con

poj-1151-Atlantis-线段树求面积并

很裸的线段树求面积并. 坐标需要离散化一下. #include<stdio.h> #include<iostream> #include<stdlib.h> #include<string.h> #include<algorithm> #include<vector> #include<math.h> #include<map> #pragma comment(linker, "/STACK:1024

编写一个矩形类,私有数据成员为矩形的长( len)和宽(wid),wid设置为0,有参构造函数设置和的值,另外,类还包括矩形的周长、求面积、取矩形的长度、取矩形的长度、取矩形的宽度、修改矩形的长度和宽度为对应的形参值等公用方法。

class Rectangle { private double len, wid; public Rectangle()//求矩形周长 { len = 0; wid = 0; } public Rectangle(int l, int w)//求矩形面积 { len = l; wid = w; } public double perimeter()//求周长 { return ((len + wid) * 2); } public double area()//求面积 { return (le

bzoj1502 simpson求面积

题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1502 题解: simpson积分求面积,s = (f(a)+f(b)+4*f(c))/6*Δx ,c=(a+b)/2. 题中的树投影下来是一些圆和相邻圆的公切线组成的一个封闭图形,并且上下对称,所以可以只求上半部分. simpson求面积时,若f(x)代价很大,要尽量减少其的重复调用.其次尽量优化f(x)函数的计算. 写完后还要自己出极限随机数据,将eps调到能接受的最大值. 1 #incl

Herding(hdu4709)三点运用行列式求面积

Herding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1553 Accepted Submission(s): 440 Problem Description Little John is herding his father's cattles. As a lazy boy, he cannot tolerate chasing t