zoukankan      html  css  js  c++  java
  • bzoj1857 [SCOI2010]传送带

    题目链接

    简单的三分套三分,精度要求也不高,随便玩。。。

     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>
    10 #include<stack>
    11 #include<map>
    12 #include<set>
    13 #define rre(i,r,l) for(int i=(r);i>=(l);i--)
    14 #define re(i,l,r) for(int i=(l);i<=(r);i++)
    15 #define Clear(a,b) memset(a,b,sizeof(a))
    16 #define inout(x) printf("%d",(x))
    17 #define douin(x) scanf("%lf",&x)
    18 #define strin(x) scanf("%s",(x))
    19 #define LLin(x) scanf("%lld",&x)
    20 #define op operator
    21 #define CSC main
    22 typedef unsigned long long ULL;
    23 typedef const int cint;
    24 typedef long long LL;
    25 using namespace std;
    26 void inin(int &ret)
    27 {
    28     ret=0;int f=0;char ch=getchar();
    29     while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();}
    30     while(ch>='0'&&ch<='9')ret*=10,ret+=ch-'0',ch=getchar();
    31     ret=f?-ret:ret;
    32 }
    33 const double eps=1e-8;
    34 double f(double x){return x*x;}
    35 struct xl
    36 {
    37     double x,y;
    38     xl(double x=0,double y=0):x(x),y(y){}
    39     void in(){douin(x),douin(y);}
    40     xl op - (const xl &rhs){return xl(x-rhs.x,y-rhs.y);}
    41     xl op + (const xl &rhs){return xl(x+rhs.x,y+rhs.y);}
    42     xl op * (const double &rhs){return xl(x*rhs,y*rhs);}
    43     xl op / (const double &rhs){return xl(x/rhs,y/rhs);}
    44 };
    45 double dis(const xl &a,const xl &b){return sqrt(f(a.x-b.x)+f(a.y-b.y));}
    46 xl A,B,C,D;
    47 double v1,v2,u;
    48 double getans(xl x)
    49 {
    50     xl l=C,r=D;
    51     while(dis(l,r)>1e-5)
    52     {
    53         xl v=r-l;
    54         xl V1=v/3.0,V2=v-V1;
    55         xl ll=l+V1,rr=l+V2;
    56         double ret1=dis(x,A)/v1+dis(ll,D)/v2+dis(ll,x)/u;
    57         double ret2=dis(x,A)/v1+dis(rr,D)/v2+dis(rr,x)/u;
    58         if(ret1<ret2)r=rr;
    59         else l=ll;
    60     }
    61     return dis(x,A)/v1+dis(l,D)/v2+dis(l,x)/u;
    62 }
    63 int CSC()
    64 {
    65     A.in(),B.in(),C.in(),D.in();
    66     douin(v1),douin(v2),douin(u);
    67     xl l=A,r=B;
    68     while(dis(l,r)>1e-5)
    69     {
    70         xl v=r-l;
    71         xl V1=v/3.0,V2=v-V1;
    72         xl ll=l+V1,rr=l+V2;
    73         if(getans(ll)<getans(rr))r=rr;
    74         else l=ll;
    75     }
    76     printf("%.2f",getans(l));
    77     return 0;
    78 }
  • 相关阅读:
    Supervisor
    JS操作JSON总结
    电脑连接海信电视 HDMI
    upupw nginx服务器 rewrite设置
    PHP实现远程图片下载
    web页面调用IOS的事件
    composer更新不成功,启用国内镜像网站的配置更改办法
    Oracle中的一连接语句
    Oracle 树操作(select…start with…connect by…prior)
    MyEclipse下Tomcat无法部署项目 finish按钮无法点击
  • 原文地址:https://www.cnblogs.com/HugeGun/p/5200453.html
Copyright © 2011-2022 走看看