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 }
  • 相关阅读:
    ans Single VIP LLB and SLB config
    Kindle支持文档类型
    RFC2544测试指标
    C#中equal与==的区别
    COGS 144. [USACO Dec07] 魅力手镯【01背包复习】
    我的第六个网页制作:table标签
    我的第五个网页制作:pre、html转义、abbr标签的使用
    我的第四个网页制作:列表标签
    我的第三个网页制作:b、i、s、u、sub、sup标签的使用
    我的第二个网页制作:p,hn,br标签的使用
  • 原文地址:https://www.cnblogs.com/HugeGun/p/5200453.html
Copyright © 2011-2022 走看看