zoukankan      html  css  js  c++  java
  • hdu 4036 2011成都赛区网络赛F 模拟 **

    为了确保能到达终点,我们需要满足下面两个条件

    1.能够到达所有山顶

    2.能够在遇到苦土豆时速度大于他

    二者的速度可以用能量守恒定律做,苦土豆的坐标可通过三角形相似性来做

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #include<queue>
    #include<map>
    using namespace std;
    #define MOD 1000000007
    const int INF=0x3f3f3f3f;
    const double eps=1e-5;
    typedef long long ll;
    #define cl(a) memset(a,0,sizeof(a))
    #define ts printf("*****
    ");
    const int MAXN=1005;
    int n,m,tt;
    struct P
    {
        double x,h;
    }node1[MAXN];
    struct PP
    {
        double x,v;
    }node2[MAXN];
    int main()
    {
        int i,j,k,w;
        double we,h;
        #ifndef ONLINE_JUDGE
        freopen("1.in","r",stdin);
        #endif
        scanf("%d",&tt);
        int ca=1;
        while(tt--)
        {
            double v0=0,temp;
            int g=20;
            scanf("%d%d%d",&n,&m,&w);
            for(i=1;i<=n;i++)
            {
                scanf("%lf%lf",&node1[i].x,&node1[i].h);
                temp=sqrt(2*g*(node1[i].h-node1[1].h));
                if(temp>v0) v0=temp;
            }
            double vx,v=0;
            for(i=1;i<=m;i++)
            {
                scanf("%lf%lf%lf",&node2[i].x,&node2[i].v,&we);
                node2[i].x+=node1[1].x;
                for(j=1;j<n;j++)
                {
                    if(node2[i].x>=node1[j].x&&node2[i].x<=node1[j+1].x)
                    {
                        h=(1.0*(node1[j+1].h-node1[j].h)/(node1[j+1].x-node1[j].x))*(node2[i].x-node1[j].x) + node1[j].h;  //bitter potatoe相对于原点的高度
                        break;
                    }
                }
                vx=sqrt(1.0*node2[i].v*node2[i].v+1.0*2*g*(h-node1[1].h));
                if(vx>v)
                    v=vx;
            }
            if(v>v0)
                printf("Case %d: %.2lf
    ",ca++,v);
            else
                printf("Case %d: %.2lf
    ",ca++,v0);
        }
    }
  • 相关阅读:
    问题账户需求分析
    UnityWebRequest_ZT
    NetworkManager网络通讯_问题汇总(四)
    NetworkManager网络通讯_NetworkLobbyManager(三)
    NetworkManager网络通讯_NetworkManager(二)
    C#关于private protected sealed Virtual/Override
    NetworkManager网络通讯_Example(一)
    Udp 异步通信(三)
    TCP Socket服务端客户端(二)
    TCP UDP基本编程(一)
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4706034.html
Copyright © 2011-2022 走看看