hdu 5858 正方形和内切圆的几何问题

来源:互联网 发布:北京理工大学网络登录 编辑:程序博客网 时间:2024/06/03 06:40


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


有关扇形的补充公式:

弧长:l=αr 

扇形的面积:s=(1/2)lr






#include<cmath>#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#define inf 0x3f3f3f3f#define ll long longusing namespace std;const double pi=3.1415926;int main(){    int T;    cin>>T;    while(T--)    {        int l;        cin>>l;        double s=(asin(1.0*sqrt(14)/4)/4-asin(1.0*sqrt(14)/8)+1.0*sqrt(7)/8)*l*l*2;        printf("%0.2f\n",s);    }    return 0;}


1 0
原创粉丝点击