HDU 4036 2011 All Network Tournament F Simulation * *

Source: Internet
Author: User

To ensure that we can reach the finish line, we need to meet the following two conditions

1. Able to reach all summits

2. Able to meet bitter potatoes faster than his

The speed of the two can be done by the law of Conservation of energy, and the coordinates of the bitter potatoes can be made by triangular similarity.

#include <cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<queue>#include<map>using namespacestd;#defineMOD 1000000007Const intinf=0x3f3f3f3f;Const Doubleeps=1e-5; typedefLong Longll;#defineCL (a) memset (A,0,sizeof (a))#defineTS printf ("*****\n");Const intmaxn=1005;intN,m,tt;structp{DoubleX,h;} NODE1[MAXN];structpp{DoubleX,v;} NODE2[MAXN];intMain () {inti,j,k,w; Doublewe,h; #ifndef Online_judge Freopen ("1.in","R", stdin); #endifscanf ("%d",&TT); intCa=1;  while(tt--)    {        Doublev0=0, temp; intg= -; 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; }        Doublevx,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 the height of the potatoe relative to the Origin .                     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\n", ca++, V); Elseprintf ("Case %d:%.2lf\n", ca++, V0); }}

HDU 4036 2011 All Network Tournament F Simulation * *

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.