P3829 SHOI2012 信用卡凸包

2022-05-19 08:22:37 字數 1224 閱讀 7807

傳送門

弧線不好處理,考慮先求出直線的總長

畫個圖發現,把直線向內移動 $r$ 以後,所有直線構成了圓心點集的凸包

然後考慮弧線的長度,容易發現弧線的長度總是圓的周長,大概證明就是直線需要經過弧線才能拐彎

因為最後拐回來了,所以繞了一圈,那麼弧線的弧度總和就是 $2\pi$

然後求所有圓心的凸包加上圓周長就好了

注意凸包的精度問題,我** $eps=1e-12$ 就會 $gg$,$eps=1e-5$ 就好了

#include#include

#include

#include

#include

using

namespace

std;

typedef

long

long

ll;typedef

double

db;inline

intread()

while(ch>='

0'&&ch<='

9')

return x*f;

}const db eps=1e-5,pi=acos(-1.0

);const

int n=1e5+7

;inline

int dcmp(db x)

struct

poi

inline poi

operator + (const poi &tmp) const

inline poi

operator - (const poi &tmp) const

inline

bool

operator

< (const poi &tmp) const

}p[n],st[n],t[5];

inline db cross(poi a,poi b)

inline db dot(poi a,poi b)

inline db len(poi a)

inline

bool cmp(const poi &a,const poi &b)

inline poi rotate(poi a,db a)

intn,tot;

inline

void

ins(db x,db y,db a)

db tubao()

intmain()

洛谷 P3833 SHOI2012 魔法樹

shoi2012 d2t3 harry potter 新學了一種魔法 可以讓改變樹上的果子個數。滿心歡喜的他找到了乙個巨大的果樹,來試驗他的新法術。這棵果樹共有n個節點,其中節點0是根節點,每個節點u的父親記為fa u 保證有fa u u。初始時,這棵果樹上的果子都被 dumbledore 用魔法清...

洛谷 P3833 SHOI2012 魔法樹

shoi2012 d2t3 harry potter 新學了一種魔法 可以讓改變樹上的果子個數。滿心歡喜的他找到了乙個巨大的果樹,來試驗他的新法術。這棵果樹共有n個節點,其中節點0是根節點,每個節點u的父親記為fa u 保證有fa u u。初始時,這棵果樹上的果子都被 dumbledore 用魔法清...

P3833 SHOI2012 魔法樹 樹鏈剖分

include define ll long long define rll register int using namespace std template typename t inline void read t x define mid l r 1 define lson rt 1,l,m...