BZOJ2829 信用卡 凸包

2022-03-29 06:13:38 字數 1127 閱讀 8193

信用卡是乙個矩形,唯四個角做了圓滑處理,使他們都是與矩形兩邊相切的1/4園,如下圖所示,現在平面上有一些規格相同的信用卡,試求其凸包的周長。注意凸包未必是多邊形,因為他有可能包含若干段圓弧。

我們發現凸包的圓弧段可以縮成乙個圓,然後將直線段向內平移,就可以組成乙個多邊形

因此對每個卡的四個圓心跑凸包,答案為凸包周長+乙個圓的周長

注意四個圓心的計算要用到向量旋轉,向量\((x,y)\)逆時針旋轉\(\alpha\)(弧度)之後會變成\((x\cos \alpha-y \sin \alpha,x \sin \alpha+y \cos \alpha)\)

#include#include#include#include#include#define eps 1e-6

#define maxn 10000

using namespace std;

int n;

const double pi=acos(-1.0);

struct vector

vector(double _x,double _y)

friend vector operator + (vector p,vector q)

friend vector operator - (vector p,vector q)

friend bool operator < (vector p,vector q)

int main()

}#ifdef debug

printf("%d\n",cnt);

for(int i=1;i<=cnt;i++)

#endif

for(int i=1;i<=cnt;i++)

double ans=0;

for(int i=1;i

ans+=dist(s[top],s[1]);

ans+=2*pi*r;

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

}

BZOJ2829 信用卡凸包

標籤 凸包 題目傳送門 description input output sample input 26.0 2.0 0.0 0.0 0.0 0.0 2.0 2.0 1.5707963268 sample output 21.66 hint 本樣例中的2張信用卡的輪廓在上圖中用實線標出,如果視1.5...

Bzoj2829 信用卡凸包

time limit 10 sec memory limit 128 mbsec special judge submit 333 solved 155 26.0 2.0 0.0 0.0 0.0 0.0 2.0 2.0 1.5707963268 21.66 本樣例中的2張信用卡的輪廓在上圖中用實線標...

bzoj2829 信用卡凸包 凸包

26.0 2.0 0.0 0.0 0.0 0.0 2.0 2.0 1.5707963268 21.66 本樣例中的2張信用卡的輪廓在上圖中用實線標出,如果視1.5707963268為 pi 2 pi為圓周率 則其凸包的周長為16 4 sqrt 2 題解 把邊上的圓去掉然後求一遍凸包,最後再加上乙個圓...