FZU 2099 魔法阵(计算几何) Problem 2099 魔法阵

Accept: 120    Submit: 289
Time Limit: 1000 mSec    Memory Limit : 32768 KB

FZU 2099 魔法阵(计算几何) Problem Description

两个正三角形和一个圆组成一个魔法阵,如图,圆心和正三角形内心重合,三角形的重叠部分是一个正六边形。求魔法阵轮廓围成的面积。

FZU 2099 魔法阵(计算几何)

FZU 2099 魔法阵(计算几何) Input

第一行一个整数T表示数据组数(T<=1000)。接下来T行每行2个实数,正三角形边长L和圆的半径R(0<L,R<1000)。

FZU 2099 魔法阵(计算几何) Output

对于每组数据输出一个实数,魔法阵轮廓围成的面积,保留2位小数。

FZU 2099 魔法阵(计算几何) Sample Input

4493.5 176.4741.7 374.0100.0 1.01.0 100.0

FZU 2099 魔法阵(计算几何) Sample Output

141994.02449787.965773.5031415.93

计算几何

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;
double l,r;
double ans;
double pi=2*asin(1.0);
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf",&l,&r);
        if(r>=l/sqrt(3.0))
            ans=pi*r*r;
        else if(r<=l/3.0)
            ans=sqrt(3.0)/3.0*l*l;
        else
        {
            double date=16*r*r-4.0/3.0*l*l;
            double x=(2*l-sqrt(date))/8;
            double s2=2*x*(l/sqrt(3.0))*1.0/2;
            double s3=pi*r*r*asin(x/r)/pi;
            double s4=s2-s3;
            ans=pi*r*r+s4*6;
        }
        printf("%.2f\n",ans);
    }
    return 0;
}



相关文章:

  • 2021-07-29
  • 2021-12-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
  • 2021-05-30
猜你喜欢
  • 2021-08-30
  • 2021-12-19
  • 2022-12-23
  • 2021-12-02
  • 2021-10-04
  • 2021-11-25
  • 2021-11-30
相关资源
相似解决方案