hdu 5858 Hard problem

本文介绍了一道针对小学奥林匹克数学竞赛的难题,任务是计算特定几何图形中阴影部分的面积。通过连接特殊点并利用三角函数计算,最终得出了解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hard problem

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


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
 

这道题是个数学题,一开始总想着切割算,结果是要加辅助线再利用三角函数。。。。差点就要用积分去算了。将靠近右边与靠近下边的交点分别与左上角顶点相连。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;
const double N=acos(-1.0);
int main()
{
    double l;
    int T;
    cin>>T;
    while(T--)
    {
        cin>>l;
        double l1,l2,l3,l4;
        l1=l*sqrt(2.0)/2;
        l2=l;
        l3=l/2;
        double z,z1;
        z=(l2*l2+l1*l1-l3*l3)/(2*l1*l2);
        z1=(l1*l1+l3*l3-l2*l2)/(2*l1*l3);
        double A,B,C;
        A=acos(z);
        B=acos(z1);
        double s1,s2,s3;
        s1=l2*l2*A/2;
        s2=l1*l2*(sqrt(1-z*z))/2;
        C=N-B;
        s3=l3*l3*C/2;
        double s;
        s=4*(s3-(s1-s2));
        printf("%.2f\n",s);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值