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 * *