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張信用卡的輪廓在上圖中用實線標出,如果視1.5707963268為
pi/2(pi為圓周率),則其凸包的周長為16+4*sqrt(2)
幾何 凸包
把矩形邊長減去圓的直徑,得到有效邊長。計算出每個矩形的四個點,找到凸包,再加上乙個圓的周長就是答案。
迷之wa,注釋掉的旋轉方法不知為何不對(小樣例居然都過了)
1/*by silvern
*/2 #include3 #include4 #include5 #include6 #include7 #include8
using
namespace
std;
9const
double pi=acos(-1.0
);10
const
int mxn=100010;11
struct
point;}
14 point operator + (point rhs);}
15}p[mxn];
1617
double cross(point a,point b)
18double dist(point a,point b)
19int
cmp(point a,point b)
23int
cmp2(point a,point b,point p)
27 point rotate(point a,double
angle);29}
30 point move(point a,double len,double
an);32}
33int
n;34
double
a,b,r;
35double
x,y,th;
36int
st[mxn],top;
37int
main(),b/2,th+pi*(j-1)/2
);48 p[++top]=move(tmp,a/2,th+pi*j/2
);49
swap(a,b);
50}
51//
point tmp;
52/*
53tmp.x=a/2;tmp.y=b/2;p[++top]=(point)+rotate(tmp,th);
54tmp.x=-a/2;tmp.y=b/2;p[++top]=(point)+rotate(tmp,th);
55tmp.x=a/2;tmp.y=-b/2;p[++top]=(point)+rotate(tmp,th);
56tmp.x=-a/2;tmp.y=-b/2;p[++top]=(point)+rotate(tmp,th);
57*/58}
59 n=top;top=0;60
int s=1;61
for(i=1;i<=n;i++)
64 swap(p[s],p[1
]);65 sort(p+2,p+n+1
,cmp);
66 p[n+1]=p[1
];67 n++;
68for(i=1;i<=n;i++)
72double ans=0
;73 ans+=pi*2*r;
74for(i=1;i)
77 printf("
%.2lf\n
",ans);
78return0;
79}80/*815
8212.0 6.0 2.0
830.0 0.0 0.0
841 1 1
852 2 1.5707963268
861 7 0
872.0 -2.0 1.5707963268
88*/
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 信用卡 凸包
信用卡是乙個矩形,唯四個角做了圓滑處理,使他們都是與矩形兩邊相切的1 4園,如下圖所示,現在平面上有一些規格相同的信用卡,試求其凸包的周長。注意凸包未必是多邊形,因為他有可能包含若干段圓弧。我們發現凸包的圓弧段可以縮成乙個圓,然後將直線段向內平移,就可以組成乙個多邊形 因此對每個卡的四個圓心跑凸包,...
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 題解 把邊上的圓去掉然後求一遍凸包,最後再加上乙個圓...