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 2e9
16 #define INF 2147483647
17 #define N 25
18 #define PI 3.141592653
19 #define EPS 1e-8
20 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  }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值