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

来源:互联网 发布:软件购销合同书范本 编辑:程序博客网 时间:2024/06/09 22:15
题目链接: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 0x3f3f3f3ftypedef 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

 

0 0
原创粉丝点击