zoukankan      html  css  js  c++  java
  • ZOJ 1104 Leaps Tall Buildings by kuangbin

    Leaps Tall Buildings

    Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

    It's a bird! It's a plane! It's coming right at us!

    Although it sometimes seems like it, Superman can't fly (without a plane). Instead, he makes super-human leaps, especially over tall buildings. Since he never knows when he will need to catch a criminal, he can't register flight paths. To avoid hitting planes, he tries to keep his jumps as low to the ground as he can. Given a city-scape as input, find the angle and velocity of Superman's jump that minimizes his maximum altitude.

    Recall that gravity provides an acceleration of 9.8 m/s2 downwards and the formula for Superman's vertical distance from his starting location is d(t)=v t + 0.5 a t2 where v is his initial velocity, a is his acceleration and tis time in seconds since the start of the leap.

    Input:

    Input consists of a sequence of city-scapes, each of the form

    n
    0 d1
    h2 d2
    :
    h(n-1) d(n-1)
    0 dn

    Superman starts at ground level and leaps d1+...+dn metres, landing at ground level and clearing all of the buildings at heights h2 to h(n-1), each with the given widths. n will be at most 100.

    Output:

    Output is the angle and initial velocity that minimizes the height that Superman attains, both appearing on the same line. The values should be given to two decimal places and be accurate within 0.01 degrees or m/s, as appropriate.

    Sample Input:

    3
    0 5
    10 5
    0 5
    5
    0 10.5
    20 11.5
    25 10
    10 15
    0 7
    

    Diagram for Second City-scape


    (Not to scale.)

    Sample Output:

    71.57 15.65
    67.07 27.16
    
     
    推公式!!!!
    #include<stdio.h>
    #include<math.h>
    const double g=9.8;
    const double PI=acos(-1.0);

    struct Node
    {
    double x,y;
    }node[210];
    int main()
    {
    //freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    int n;
    int t;
    double w,hm;
    double a,b;
    while(scanf("%d",&n)!=EOF)
    {
    t=0;
    double h;
    double d;
    scanf("%lf%lf",&h,&d);//第一行
    w=d;
    for(int i=1;i<n-1;i++)
    {
    scanf("%lf%lf",&node[t].y,&d);
    node[t].x=w;
    t++;
    w+=d;
    node[t].y=node[t-1].y;
    node[t].x=w;
    t++;
    }
    scanf("%lf%lf",&h,&d);
    w+=d;
    double tmp;
    hm=0;

    //printf("%lf\n",w);

    for(int i=0;i<t;i++)
    {
    tmp=w*w*node[i].y/(-node[i].x*node[i].x+w*node[i].x)/4;
    if(tmp>hm)hm=tmp;
    }
    double res1=atan(4*hm/w)*180/PI;
    double res2=sqrt(g*w*w/(8*hm)+2*g*hm);
    printf("%.2lf %.2lf\n",res1,res2);
    }
    return 0;
    }
    
    
  • 相关阅读:
    80386寄存器
    删除 Windows 旧 OS 加载器
    [C#] Socket 通讯,一个简单的聊天窗口小程序
    [erl] erlang 进程注册和注销
    VB中 '&' 和 '+' 号的区别
    如何成为一个牛逼的程序员
    [VB] if 判断语句 和 If、IIf函数的比较
    C#中通过反射方法获取控件类型和名称
    薪资至少10K的一道题,你能拿下吗
    Jass 技能模型定义(—):半人马酋长的反击光环
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2250425.html
Copyright © 2011-2022 走看看