HDU 5858 Hard problem (2016 多校训练#10 1002)

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5858

题意:给出下图和正方形边长,求阴影部分面积。

分析:数学题,总之就是割来割去推公式,比赛时是队友打的,拿他代码直接贴了。

具体分析可以看这里。

http://www.zybang.com/question/1301cb472211299680f8d4796e7dc797.html

代码:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
int main()
{
    double PI=acos(-1.0);
    int t;
    scanf("%d",&t);
    while(t--)
    {
        double l;
        scanf("%lf",&l);
        double bac=(4-PI)*l*l;
        double bef=(4-PI)/4*l*l;
        double gae=0.5*(3*l)*l-0.5*2*l*l*sin(acos(0.75))-(PI/4-acos(5*sqrt(2)/8))/(2*PI)*PI*4*l*l-(acos(0.75)+acos(5*sqrt(2)/8)-PI/4)/(2*PI)*PI*l*l;
        printf("%.2f\n",0.5*(bac-bef-2*gae));
    }
}
View Code

 

posted @ 2016-08-18 21:51  wwdf  阅读(420)  评论(0编辑  收藏  举报