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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章