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;
    }
    
    
  • 相关阅读:
    项目管理5大过程组,42个过程一句话讲解
    在命令中输入信息创建maven项目
    《Maven应用实战》一书的在线学习网址和源码链接
    [转]使用Eclipse创建一个简单的servlet项目
    使用Maven客户端从Maven中心仓库下载到本地的jar包的默认存储位置及远程仓库
    ant利用ivy从maven仓库下载项目所依赖的jar包默认的存储位置
    Ant和Ivy集成部署和使用
    Ant入门简单实例
    TIBCO Jaspersoft Studio-6.12.2连接mysql时显示时区问题
    JAVA Swing日期选择控件datepicker的使用
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2250425.html
Copyright © 2011-2022 走看看