HDU 5858 Hard problem 2016多校10 1002 [相交圆面积]【计算几何】

该博客介绍了如何解决一道涉及计算几何的数学问题,具体是求解正方形内切圆与四分之一圆相交形成的阴影部分面积。博主分享了解题思路,从最初尝试割补法失败,到后来利用相交圆面积公式解决问题。题目要求给出正方形边长并保留两位小数。博主提醒,等比例放大图形时,面积会按比例平方增长,并提供了相应代码。

题目连接 : 就当前HDU的情况 就先不给了

——————————————————————–.
Hard problem

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

Problem Description
cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school students. It is too difficult for cjj. Can you solve it?
这里写图片描述

Give you the side length of the square L, you need to calculate the shaded area in the picture.

The full circle is the inscribed circle of the square, and the center of two quarter circle is the vertex of square, and its radius is the length of the square.

Input
The first line contains a integer T(1<=T<=10000), means the number of the test case. Each case contains one line with integer l(1<=l<=10000).

Output
For each test case, print one line, the shade area in the picture. The answer is round to two digit.

Sample Input
1
1

Sample Output
0.29

———————————————-.
题目大意 : 就是正方形边长为n时 求阴影面积 保留小数后两位

题目分析 :
当天不想做多校 然后队友给看了这题 说是小学奥数题目 所以就一直割补法 然后 GG
今天偶然看了看过去整理的模板 猛然看到一个叫做相交圆面积的东西 然后就想到了这道题目。。

然后大致是这样的。
这里写图片描述

小的圆是蓝的 打的圆是红的 绿色部分是相交的面积 (红色+蓝色==绿色?就当是对的了:不可能错)

然后根据相交圆面积求绿色部分 最后拿小圆的面积减去它 最后在乘个二就行了。。。

之后做题的时候只求一次边长为1的阴影部分面价就好了 因为平面图形 等比放大N倍 面积就是原来的n*n倍

#

就是这么水 然而被第一句话误导了 一直在寻找巧妙的办法…
什么小学奥数题目。。。 小学能学这个??!!!

附本题代码
———————————————–.

#include <bits/stdc++.h>
using namespace std;
#define lalal puts("*******");
const double PI  =  acos(-1);

struct Round {
    double x, y;
    double r;
}c1,c2;

double dis(Round a, Round b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

double solve(Round a, Round b)
{
    double d = dis(a, b);
    if (d >= a.r + b.r)  return 0;

    if (d <= fabs(a.r - b.r))
    {
        double r = a.r < b.r ? a.r : b.r;
        return PI * r * r;
    }

    double ang1 = acos((a.r * a.r + d * d - b.r * b.r) / 2. / a.r / d);
    double ang2 = acos((b.r * b.r + d * d - a.r * a.r) / 2. / b.r / d);
    double ret = ang1 * a.r * a.r + ang2 * b.r * b.r - d * a.r * sin(ang1);
    return ret;
}

int main()
{
    c1.x=0.0,c1.y=0.0,c1.r=1.0;
    c2.x=0.5,c2.y=0.5,c2.r=0.5;

    double s = solve(c1,c2);
    s = PI*0.5-s*2;
  //  printf("%.15lf\n",s);

    int _,n;
    scanf("%d",&_);
    while(_--)
    {
        scanf("%d",&n);
        printf("%.2lf\n",s*n*n);
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值