HDU-5858-Hard problem

Hard problem

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


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<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double PI=acos(-1.0);
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double l;
        scanf("%lf",&l);
        double ans=acos((double)(5*sqrt(2)*1.0)/8.0);
        ans=ans*1.0/PI*180.0;//求弧度
        ans*=2;//求完整的角
        double shan1=ans*1.0/360*1.0*PI*l*l;//求扇形面积
        double sanjiaoxing=sqrt(7*1.0/32*1.0)*5*sqrt(2.0)/8.0*l*l;
        double xiaogongxing=shan1-sanjiaoxing;
        double ans2=acos((double)(-sqrt(2)*1.0/4.0));
        ans2=ans2/PI*180.0;
        ans2=180-ans2;
        ans2*=2;
        double shan2=ans2*1.0/360*1.0*PI*(l*1.0/2*1.0)*(l*1.0/2*1.0);
        double sanjiaoxing2=sqrt(7*1.0/32*1.0)*sqrt(1*1.0/32*1.0)*l*l;
        double dagongxing=(shan2-sanjiaoxing2);
        printf("%.2lf\n",2*(dagongxing-xiaogongxing));
    }
}


猜你喜欢

转载自blog.csdn.net/lee371042/article/details/80014723
今日推荐