首页 > 代码库 > 1001 A Curious Matt

1001 A Curious Matt

·签到题

·题意: 给出一系列时间与对应位置坐标,求出最大速度

·对其按时间排序,之后求商(即速度)的最大值即可

Code:

 1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <cstring> 5 #include <string.h> 6 #include <math.h> 7 #include <queue> 8 #include <stack> 9 #include <stdlib.h>10 #include <map>11 using namespace std;12 13 #define LL long long 14 #define sf(a) scanf("%d",&(a));15 #define inf 2e916 #define INF 214748364717 #define N 2518 #define PI 3.14159265319 #define EPS 1e-820 struct LNode{21  int t,x;22  }f[10010];23 24  int cmd(LNode x,LNode y){25  return x.t < y.t;26  }27  int main(){28  int T,n;int k=1;29  //printf("%06d  %d %f\n",y)x;30  scanf("%d",&T);31  while(T--){32  scanf("%d",&n);33  for(int i=0;i<n;i++){34  scanf("%d %d",&f[i].t,&f[i].x);35  }36  sort(f,f+n,cmd);37  double maxc=0;38  for(int i=1;i<n;i++){39  double t = ((double)(abs(f[i].x-f[i-1].x))/(f[i].t-f[i-1].t));40  if(t > maxc) maxc = t;41  }42  printf("Case #%d: ",k++);43  printf("%.2f\n",maxc);44  }45  return 0;46  }

 

1001 A Curious Matt