题解去看它
精度真是卡的我醉生梦死,w(゚Д゚)w O(≧口≦)O
bzoj改成long double 就过了
洛谷仍处于
输出x.99999,答案输出x+1.00000
输出-0.00000,答案输出0.00000
救命啊~~~~(>_<)~~~~
来自大佬的建议:输出double时用%f
#include#include #include #define N 50001 using namespace std; const long double eps=1e-10; int dcmp(long double x){ if(fabs(x) 1 && Cross(c[m-1]-c[m-2],p[i]-c[m-2])<=0) m--; c[m++]=p[i]; } int k=m; for(int i=n-2;i>=0;--i) { while(m>k && Cross(c[m-1]-c[m-2],p[i]-c[m-2])<=0) m--; c[m++]=p[i]; } m--; return m;} long double getdis(Point A,Point B){ return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));} void RotatingCaliper(Point *c,int m){ long double AnsArea=1e20,AnsPeri=1e20; int q=1,l=0,r=0; long double d,h,w,rw; for(int p=0;p fabs(Cross(c[p]-c[p+1],c[q]-c[p+1]))) q=(q+1)%m; while(dcmp(Dot(c[p+1]-c[p],c[r+1]-c[r]))>0) r=(r+1)%m; if(!l) l=q; while(dcmp(Dot(c[p+1]-c[p],c[l+1]-c[l]))<0) l=(l+1)%m; d=Length(c[p+1]-c[p]); h=fabs(Area2(c[p],c[p+1],c[q]))/d; w=Dot(c[p+1]-c[p],c[r]-c[l])/d; rw=Dot(c[r]-c[p],c[p+1]-c[p])/d; if(w*h