1. 程式人生 > >HDU 5858 Hard problem(計算幾何)

HDU 5858 Hard problem(計算幾何)

Time Limit: 2000/1000 MS (Java/Others)   

 Memory Limit: 65536/65536 K (Java/Others)


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 題意:  求變成為length的正方形中陰影部分的面積;
思路:

建座標系積分就好了;以參考資料中的D點為原點,然後得到兩個圓的方程,聯立求交點得到積分割槽間,然後積分,積分的時候借用三角函式;  http://zhidao.baidu.com/question/571519797

另一種解法也可以用以正方形的中心為原點,以對角線為水平軸,然後得到兩個圓的方程,聯立求交點得到積分割槽間,然後積分。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <list>
#define LL long long
#define eps 1e-8
#define maxn 110
#define mod 100000007
#define inf 0x3f3f3f3f
#define mid(a,b) ((a+b)>>1)
#define IN freopen("in.txt","r",stdin);
using namespace std;

int main(int argc, char const *argv[])
{
    //IN;

    int t; cin >> t;
    while(t--)
    {
        double a; scanf("%lf", &a);

        //double ans = a*a/4.0 * asin(sqrt(14.0)/4.0);
        //ans -= a*a * asin(sqrt(14.0)/8.0);
        //ans += a*a * sqrt(7.0) / 8.0;
        //ans *= 2.0;

        double ans = atan(sqrt(7.0)) / 4.0;
        ans -= atan(sqrt(7.0)/5.0);
        ans += sqrt(7.0) / 8.0;
        ans *= a*a*2.0;

        printf("%.2f\n", ans);
    }

    return 0;
}


相關推薦

HDU 5858 Hard problem計算幾何

Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description cjj is fun with math prob

HDU 5858 Hard problem計算幾何【較難】【多校聯合8.18】

解題思路: 看懂這個圖,這個題就能A掉了。 下面是AC程式碼: #include<cstdio> #include<cstring> #include<c

hdu 6127 : Hard challenge (2017 多校第七場 1008計算幾何

for %d logs opera log val r+ ++ show 題目鏈接 題意:二維平面上有n個點(沒有重疊,都不在原點,任意兩點連線不過原點),每個點有一個權值,用一條過原點的直線把他們劃分成兩部分,使兩部分的權值和的乘積最大。輸出最大的乘積。 極角排序後,將原

HDU-5858 Hard problem(數學公式、計算幾何)

題意: 已知正方形邊長,圓是內切圓,1/4圓半徑等於正方形邊長,求圖中陰影部分的面積。 思路: 對於我這種高中畢業之後就再沒做過幾何的人還是挺困難的,亂七八糟的公式都忘掉了。 做完輔助線之後,其實就

HDU 6055 17多校 Regular polygon計算幾何

ati sort 結果 stream int tom tle eight idt Problem Description On a two-dimensional plane, give you n integer points. Your task is to figur

HDU 4173 Party Location計算幾何,枚舉

mes def air 思路 lib gpo 畫畫 ons dsm HDU 4173 題意:已知n(n<=200)位參賽選手的住所坐標。現要邀請盡可能多的選手來參加一個party,而每一個選手對於離住所超過2.5Km

今日頭條杯 2018 年首屆湖北省大學生程式設計競賽 (網路賽)Problem B.計算幾何

Problem B. GSS and Interesting SculptureInput file: standard inputOutput file: standard outputTime limit: 1 secondsMemory limit: 512 mebib

HDU 5120 Intersection 計算幾何

題意: 求兩個一模一樣,但位置不一定相同的圓環的環相交面積 分析: 其實就是圓交面積++−− ans=大圓交−2∗一大一小圓交+小圓交 寫圓交函數的時候,注意有三種情況,相含,相交,相離 把重合當成相含了, 一直沒考慮相含卡

HDU 5120 Intersection 計算幾何2014ICPC 北京站現場賽

Intersection Time Limit: 4000/4000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 1253    Accepte

5858 Hard problem 非常詳細的解答

cjj is fun with math problem. One day he found a Olympic Mathematics problem for primary school

[POJ2826]An Easy Problem?!計算幾何-細節/距離

題目: 我是超連結 題意: 給出兩條線段,雨水從空中豎直落下,問線段上能積多少水。 題解: 一道特判超~~~多的題目,下見註釋咯 這道題精度會有-0.00?!加個fabs吧。 這題的題解。。。真是敷衍啊 那就加個對於距離的講解吧,雖然這個

HDU 5120 Intersection計算幾何

Description 給出兩個圓環的內外半徑和圓心座標,問這兩個圓環的相交面積 Input 第一行為一整數T表示用例組數,每組用例第一行兩個整數r和R分別表示圓環內外半徑,第二行和第三行為兩個圓

Codeforces 849B Tell Your World 計算幾何

continue int ++i 滿足 light size sizeof tar tell 題目鏈接 Tell Your World 題意 給出N個點(i, xi),問是否存在兩條平行的直線,使得每一個點恰好在兩條直線的其中一條上。 每條直線必須穿過至少一個點。 考

POJ 2318 TOYS 計算幾何叉積的運用

line sync ted all names pri char ems sizeof Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have

51 Nod 1298 圓與三角形計算幾何

tput body bits truct 大於 簡單 以及 else c++ 題目鏈接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1298 題目: 1298 圓與三角形

POJ - 1039 Pipe計算幾何

std algo double 透明 pac down queue == 是否 http://poj.org/problem?id=1039 題意 有一寬度為1的折線管道,上面頂點為(xi,yi),所對應的下面頂點為(xi,yi-1),假設管道都是不透明的,不反射的,光

HDU - 5858 Hard Problem (simpson積分)

asr \n int show turn push first 陰影部分 bubuko 原題鏈接 題意: 給定一個邊長為n的正方形,求陰影部分面積 思路: 現將圖形順時針旋轉 45° 然後建立坐標系,寫出陰影部分方程,用Simpson積分算一下就行

Thinking-Bear magic 計算幾何

return name code 數加 重復 ack tps href tac ---- 點我 ---- 題目大意: 給你一個正n邊形及邊長 a和一個正整數L, 求正多邊形的面積s,若s大於L,則連接相鄰兩邊的中點,形成新的正多邊形,重復這個操作直至s小於L:如圖:

【HDOJ5538】House Building計算幾何

for fine tdi ++ spa memset 其余 building while 題意:給定一個n*m的方陣,第i行第j列的高度為a[i][j],問除了下底面之外其余五面的總表面積 n<=50,0<=a[i][j]<=1000 思路:隊友寫的,抱大

Newcoder 110 B.簡單多邊形計算幾何

Description 為了讓所有選手都感到開心, N o w