zoukankan      html  css  js  c++  java
  • 【HDOJ5979】Convex(三角函数)

    题意:n个点在一个半径为R的圆上,给出这n个点顺时针的夹角差值,求这n个点的凸包面积

    n<=10,R<=10

    思路:S=1/2*sinθ*a*b

    角度转弧度再用sin

    C++有点小毛病,叫队友改了下

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<string>
     4 #include<cmath>
     5 #include<iostream>
     6 #include<algorithm>
     7 #include<map>
     8 #include<set>
     9 #include<queue>
    10 #include<vector>
    11 using namespace std;
    12 typedef long long ll;
    13 typedef unsigned int uint;
    14 typedef unsigned long long ull;
    15 typedef pair<int,int> PII;
    16 typedef vector<int> VI;
    17 #define fi first
    18 #define se second
    19 #define MP make_pair
    20 #define N   1100000
    21 #define MOD 1000000007
    22 #define eps 1e-8
    23 #define pi  acos(-1)
    24 
    25 
    26 int n;
    27 double L;
    28 
    29 
    30 int read()
    31 {
    32    int v=0,f=1;
    33    char c=getchar();
    34    while(c<48||57<c) {if(c=='-') f=-1; c=getchar();}
    35    while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar();
    36    return v*f;
    37 }
    38 
    39 int main()
    40 {
    41     while(scanf("%d%lf",&n,&L)!=EOF)
    42     {
    43          double ans=0;
    44          for(int i = 1; i <= n; ++i)
    45          {
    46              double x;
    47              scanf("%lf",&x);
    48              x/=180*1.0;
    49              x*=pi*1.0;
    50              ans+=1.0/2*L*L*sin(x);
    51          }
    52          printf("%.3lf
    ",ans);
    53     }
    54     return 0;
    55 }
  • 相关阅读:
    nginx入门与实战
    python开发之virtualenv与virtualenvwrapper讲解
    Linux下的python3,virtualenv,Mysql、nginx、redis安装配置
    Linux系统基础优化及常用命令
    vim与程序员
    Shell基本命令
    Linux之文档与目录结构
    远程连接Linux
    oracle 根据时间戳查询date类型sql
    oracle 锁用户
  • 原文地址:https://www.cnblogs.com/myx12345/p/9747650.html
Copyright © 2011-2022 走看看