Hard problem
程序员文章站
2022-06-08 08:11:24
...
Hard problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 497 Accepted Submission(s): 326
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.
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
11
Sample Output
0.29
给出正方形边长L。BD为圆的半径为L/2,BA为正方形对角线的1/2,AD为1/4圆AEF的半径为L,则能根据余弦定理求出∠a,进而求出∠b,进而求出扇形ACD的面积以及三角形ABD的面积。用扇形ACD的面积减去两倍的三角形ABD的面积为饼BCD的面积。然后根据三角形ABD的三边求得∠c,进而求得∠d,进而求得以B为圆心的扇形BCD的面积,然后用扇形BCD的面积减去饼BCD的面积即为阴影部分的面积,然后乘以2即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<string>
#define LL long long
using namespace std;
double pi=acos(-1);
const int maxn=1000;
int a[maxn],b[maxn];
int main()
{
int cases;
double r;
scanf("%d",&cases);
while(cases--)
{
cin >> r;
double s1 = 2* sqrt(7)/16 * r *r; // 两个三角形的面积
double a = sqrt(7)*5/16;
double s2 = asin(a)/(2*pi) * pi * r * r; // 大扇形面积
double b = sqrt(7)/4;
double s3 = (pi-asin(b))/(2*pi) * pi * (r/2) * (r/2); //小扇形面积
printf("%.2lf\n", 2*(s3+s1-s2) );
}
return 0;
}
上一篇: Problem03 无重复的最长子串
下一篇: php数组中删除元素之重新索引的方法
推荐阅读
-
pip 错误unused-command-line-argument-hard-error-in-future解决办法
-
HDU 2256Problem of Precision(矩阵快速幂)
-
cfE. Ehab and a component choosing problem(贪心)
-
Problem01 不死神兔
-
HDUacm 1000 A + B Problem
-
数据结构(线性结构习题)Problem A: 求集合的交并补集
-
Problem09 求完数
-
洛谷P1919 【模板】A*B Problem升级版(FFT快速傅里叶)
-
Notice: Trying to get property of non-object problem(PHP)解决办法
-
source .bashrc 报错:virtualenvwrapper.sh: There was a problem running the initialization hooks.