hdu 5078(2014鞍山现场赛 I题)
数据 表示每次到达某个位置的坐标和时间 计算出每对相邻点之间转移的速度(两点间距离距离/相隔时间) 输出最大值
Sample Input
2
5
2 1 9//t x y
3 7 2
5 9 0
6 6 3
7 6 0
10
11 35 67
23 2 29
29 58 22
30 67 69
36 56 93
62 42 11
67 73 29
68 19 21
72 37 84
82 24 98
Sample Output
9.2195444573
54.5893762558
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <algorithm> 5 # include <string> 6 # include <cmath> 7 # include <queue> 8 # include <list> 9 # define LL long long 10 using namespace std ; 11 12 struct Point 13 { 14 double x,y,t; 15 16 }p[1010]; 17 18 double dist(Point a,Point b) 19 { 20 return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 21 } 22 23 int main() 24 { 25 //freopen("in.txt","r",stdin) ; 26 int T ; 27 scanf("%d" , &T) ; 28 while(T--) 29 { 30 int n ; 31 scanf("%d" , &n) ; 32 int i ; 33 double Max = 0 ; 34 for (i = 0 ; i < n ; i++) 35 { 36 scanf("%lf %lf %lf" , &p[i].t , &p[i].x , &p[i].y) ; 37 } 38 for (i = 0 ; i < n-1 ; i++) 39 { 40 double t = dist(p[i], p[i+1]) ; 41 t = t / (p[i+1].t - p[i].t) ; 42 if (t > Max) 43 Max = t ; 44 } 45 printf("%.10lf\n" , Max) ; 46 47 48 49 } 50 return 0; 51 }