HDU5858 Hard problem

来源:互联网 发布:淘宝注册页面html模板 编辑:程序博客网 时间:2024/06/15 00:01

Hard problem

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


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
11
 

Sample Output
0.29
 


——————————————————————————————————————————
题目的意思是给出正方形边长求阴影部分面积。
思路:小学奥数题,分析计算
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <map>#include <cmath>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;const double pi=acos(-1);int main(){    double l;    double k=sqrt(2.0);    int T;    for(scanf("%d",&T); T--;)    {        scanf("%lf",&l);        double x=acos(5.0/(4*k));        double y=acos(-k/4);        double z=2*pi-2*y;        double w=pi-z;        double s4=k*l*l*sin(y)/8;        double s3=x*l*l;        double s1=s3-2*s4;        double s2=w*l*l/8;        double s5=pi*l*l/4;        printf("%.2f\n",s5-2*s1-2*s2);    }    return 0;}


原创粉丝点击