HDU 5120 A Curious Matt(2014北京赛区现场赛A题 简单模拟)

时间:2021-11-09 19:44:19

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5112

解题报告:扫一遍

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 1e6+; struct node
{
double t,x;
}rec[maxn];
double Max(double a,double b)
{
return a > b? a : b;
}
bool cmp(node a,node b)
{
return a.t < b.t;
}
double Fabs(double d)
{
return d > ? d:-1.0*d;
}
int main()
{
int T,n,kase = ;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i = ;i < n;++i)
scanf("%lf%lf",&rec[i].t,&rec[i].x);
sort(rec,rec+n,cmp);
double ans = ;
for(int i = ;i < n;++i)
ans = Max(ans,Fabs(rec[i].x-rec[i-].x) / (rec[i].t - rec[i-].t));
printf("Case #%d: %.2lf\n",kase++,ans);
}
return ;
}