zoukankan      html  css  js  c++  java
  • HDU-5979

    Convex

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
    Total Submission(s): 1378    Accepted Submission(s): 923


    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 contain 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

    题意:

    给n个点,每个点距顶点的距离都是d,给出每两点与顶点连线之间的角度,求所形成的凸包的上表面积。

    三角形S==0.5*a*b*sinc

    注意 ,sin操作的是弧度而非角度,故要转换成弧度:

    弧度==角度*PI/180   (PI=acos(-1.0))。

    AC代码:

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 
     4 #define PI acos(-1.0) 
     5 
     6 int main(){
     7     ios::sync_with_stdio(false);
     8     int n,d,x;
     9     double sum=0;
    10     while(cin>>n>>d){
    11         sum=0;
    12         for(int i=0;i<n;i++){
    13             cin>>x;
    14             sum+=0.5*d*d*sin(x*1.0*PI/180);
    15         }
    16         printf("%.3lf
    ",sum);
    17     }
    18     return 0;
    19 }
  • 相关阅读:
    bzoj 1087: [SCOI2005]互不侵犯King
    左偏树+菲波那切堆
    bzoj 4455: [Zjoi2016]小星星
    luogu P1941 飞扬的小鸟
    luogu P2814 家谱
    平衡树之非旋Treap
    luogu P3147 [USACO16OPEN]262144
    luogu P1854 花店橱窗布置
    计蒜客NOIP2018模拟1
    [BZOJ3456]城市规划(生成函数+多项式求逆+多项式求ln)
  • 原文地址:https://www.cnblogs.com/Kiven5197/p/7875260.html
Copyright © 2011-2022 走看看