polygon

polygon
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 38(28 users) Total Accepted: 29(27 users) Rating: Special Judge: No
Description

We have a special polygon that all points have the same distance to original point.As you know

we can get N segments after linking the original point and the points on the polygon,

then 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 polygon.

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 original point. (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 numbe indicating the area of the polygon. The printed value 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

Hint
原点在多边形内部,各顶点与原点相连得到相邻两线段夹角小于180度
Author
陈禹@HRBUST

题目大意: 给你一个多边形,多边形中间有一个点,多边形上的点距离这个原点都相等,已知这个距离和相邻两个点与这个原点组成的夹角

求面积

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
int N;
double d;
double PI=atan(1)*8;
int main()
{
    //cout<<PI<<endl;
    while(~scanf("%d%lf",&N,&d))
    {
        double ans;
        double sum=0;
        int i;
        for(i=0;i<N;i++)
        {
            scanf("%lf",&ans);
            ans=ans/360*PI;
            sum+=d*d*sin(ans)/2;
        //    cout<<sin(ans)<<endl;
        }
        printf("%.3lf\n",sum);
    }
    return 0;
}
时间: 2024-12-28 16:17:35

polygon的相关文章

使用GPC分解多边形样例(Generic Polygon Clipper)

使用GPC分解多边形 (Owed by: 春夜喜雨 http://blog.csdn.net/chunyexiyu 转载请标明来源) GPC: Generic Polygon Clipper GPC支持分解多边形.多边形求差集.交集,异或.并集 GPC_DIFF,                         /* Difference                        */ GPC_INT,                          /* Intersection    

[LeetCode] Convex Polygon 凸多边形

Given a list of points that form a polygon when joined sequentially, find if this polygon is convex (Convex polygon definition). Note: There are at least 3 and at most 10,000 points. Coordinates are in the range -10,000 to 10,000. You may assume the

ACdream 1429 Rectangular Polygon

Rectangular Polygon Time Limit: 1000MS   Memory Limit: 256000KB   64bit IO Format: %lld & %llu Description A rectangular polygon is a polygon whose edges are all parallel to the coordinate axes. The polygon must have a single, non-intersecting bounda

libgdx 裁剪多边形(clip polygon、masking polygon)

直接放例子代码,代码中以任意四边形为例,如果需要做任意多边形,注意libgdx不能直接用ShapeRender填充多边形,需要先切割成三角形. public static void drawClip(Batch batch, Polygon polygon, TextureRegion region, float x, float y) { float[] vertices = polygon.getVertices(); if (shapes == null) { shapes = new S

Scrambled Polygon(差集排序)

Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7799   Accepted: 3707 Description A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the

hunnu11562:The Triangle Division of the Convex Polygon(第n个卡特兰数取模)

Problem description   A convex polygon with n edges can be divided into several triangles by some non-intersect diagonals. We denote d(n) is the number of the different ways to divide the convex polygon. For example,when n is 6,there are 14 different

[算法]Comparison of the different algorithms for Polygon Boolean operations

Comparison of the different algorithms for  Polygon Boolean operations. Michael Leonov 1998 http://www.angusj.com/delphi/clipper.php#screenshots http://www.complex-a5.ru/polyboolean/comp.html http://www.angusj.com/delphi/clipper.php#screenshots Intro

【ASC 23】G. ACdream 1429 Rectangular Polygon --DP

题意:有很多棍子,从棍子中选出两个棍子集合,使他们的和相等,求能取得的最多棍子数. 解法:容易看出有一个多阶段决策的过程,对于每个棍子,我们有 可以不选,或是选在第一个集合,或是选在第二个集合 这三种决策.因为两个集合最后的和要相等,那么令一个集合为正,另一个为负,那么最后和为0,我们用偏移0的量来作为状态之一. dp[i][j]表示前 i 个 偏移量为 j 的最大棍子数,因为每根棍最长为200,所以偏移量最多为+-20000,所以在+-20000之间枚举,最多100*40000 代码: #in

在Tableau中自定义版块地图 (Polygon)

在Tableau的地图报表中有一个‘Filed Map’的类型,可以根据版块来显示数据. 但实际应用中Tableau固有的版块划分可能不是我们想要的,下面介绍如何自定义版块并且用作数据分析. 自定义版块 在Tableau中自定义版块是非常容易的.如下图我们把每个点链接起来就是一个多边形的版块 上面的经纬度就不用说了.State 是我们版块的名字.其中Point Order告诉Tableau链接的顺序. Polygon ID 用来指定各个闭合的区域.如下图,State 都叫Michigan,由两块