Topic links
Simple three-point set of three points, precision requirements are not high, casual play ...
1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharCh=GetChar (); in while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} - while(ch>='0'&&ch<='9') ret*=Ten, ret+=ch-'0', ch=GetChar (); toret=f?-Ret:ret; + } - Const Doubleeps=1e-8; the DoubleFDoublex) {returnx*x;} * structXL $ {Panax Notoginseng Doublex, y; -xlDoublex=0,Doubley=0): X (x), Y (y) {} the void inch() {Douin (x), Douin (y);} +XL op-(ConstXL &RHS) {returnXL (x-rhs.x,y-rhs.y);} AXL OP + (ConstXL &RHS) {returnXL (x+rhs.x,y+rhs.y);} theXL OP * (Const Double&RHS) {returnXL (x*rhs,y*RHS);} +XL OP/(Const Double&RHS) {returnXL (x/rhs,y/RHS);} - }; $ DoubleDisConstXL &a,ConstXL &b) {returnsqrt (f (a.x-b.x) +f (a.y-b.y));} $ XL a,b,c,d; - DoubleV1,v2,u; - DoubleGetans (XL x) the { -XL l=c,r=D;Wuyi while(Dis (l,r) >1e-5) the { -XL v=r-l; WuXL v1=v/3.0, v2=v-V1; -XL ll=l+v1,rr=l+V2; About DoubleRet1=dis (x,a)/v1+dis (ll,d)/v2+dis (ll,x)/u; $ DoubleRet2=dis (x,a)/v1+dis (rr,d)/v2+dis (rr,x)/u; - if(Ret1<ret2) r=RR; - ElseL=ll; - } A returnDis (x,a)/v1+dis (l,d)/v2+dis (l,x)/u; + } the intCSC () - { $A.inch(), B.inch(), C.inch(), D.inch(); the Douin (v1), Douin (v2), Douin (U); theXL l=a,r=B; the while(Dis (l,r) >1e-5) the { -XL v=r-l; inXL v1=v/3.0, v2=v-V1; theXL ll=l+v1,rr=l+V2; the if(Getans (LL) <getans (RR)) r=RR; About ElseL=ll; the } theprintf"%.2f", Getans (L)); the return 0; +}
bzoj1857 [SCOI2010] conveyor belt