POJ 3575 計算幾何與二分 無盡的小數處理)

2021-06-10 07:29:12 字數 1383 閱讀 9820

這題 寫了將近半個月……總是在d各種bug

總的說來-這題最難應該是在精度處理上

0 0 1

這組資料過了就說明精度處理差不多了……

program kingdom;

const

maxn=100;

maxm=100;

le=0.000000001;

type

circle=record

x,y,r:double;

end;

var s:array[1..maxn,1..1000] of circle;

n,i,j,k:longint;

m:array[1..maxn] of longint;

ans:array[1..maxn,1..4] of double;

wanted:array[1..maxn] of double;

b:array[1..maxn] of boolean;

l,r:double;

function arccos(cosa:double):double;

var sina,tana:double;

begin

if cosa=0 then exit(pi/2);

sina:=sqrt(1-sqr(cosa));

tana:=sina/cosa;

exit(arctan(tana));

end;

function min(a,b:double):double;

begin

if ab then exit(a) else exit(b);

end;

function sector(a,r:double):double;

begin

exit(a*r*r/2);

end;

function ********(a,r:double):double;

begin

exit(sin(a)*r*r/2);

end;

function inlside(s:circle;l:double):boolean;

begin

if (s.x-s.r>l) or (abs(s.x-s.r-l)r then

begin

a:=arccos((r-s.x)/s.r)*2;

s3:=sector(a,s.r);

s4:=********(a,s.r);

s2:=s2-(s3-s4);

end;

exit(s2-s1);

endelse

if (s.x>=r) then

begin

a:=arccos((s.x-r)/s.r)*2;

if (abs(s.x-r)

POJ2002 Squares 計算幾何,二分

給定一堆點,求這些點裡哪些點可以構成正方形,題目給定n 1000,直接列舉四個點是肯定會超時的,因此要做一些優化。有公式,已知兩個點在正方形對角,分別是 x1,y1 和 x2,y2 那麼圍成正方形後另外兩個點 x3,y3 和 x4,y4 分別為 x3 x2 x2 y1 y3 x2 x2 x1 x4 ...

POJ 3808(幾何,二分)

2015 04 13 21 52 25 思路 japan 2009 的題.japan果然老喜歡幾何了.題意很精簡,在乙個三角形內嵌入三個圓,每個角對應乙個圓。已知三角形三個點的座標,求三個圓的半徑。蒟蒻不會.看的紅書的思路.我們可以二分列舉乙個圓的半徑 r1,然後根據下圖,可以列出方程 r1 tan...

計算幾何 二分求冪

如何快速求解 a 的 b次冪?王道機試指南 p85 待整理 題目 九度1441 1442 1443 include include using namespace std 題目要求最後三位,故中間值也只用保留三位即可,可避免了中間值太大導致無法儲存 int main b 2 a a 下一位二進位制的...